Submission #63556854


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+10;
int b[N],w[N],s[N];
bool cmp(int x,int y){
return x>y;
}
signed main(){
// freopen("abc.in","r",stdin);
// freopen("abc.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m;
cin>>n>>m;
for(int i = 1;i<=n;i++){
cin>>b[i];
}
for(int j = 1;j<=m;j++) cin>>w[j];
sort(b+1,b+n+1,cmp);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+10;
int b[N],w[N],s[N];
bool cmp(int x,int y){
	return x>y;
}
signed main(){
//	freopen("abc.in","r",stdin);
//	freopen("abc.out","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i = 1;i<=n;i++){
		 cin>>b[i];
	} 
	for(int j = 1;j<=m;j++) cin>>w[j];
	sort(b+1,b+n+1,cmp);
	sort(w+1,w+m+1,cmp);
	for(int i = 1;i<=m;i++){
		s[i] = s[i-1]+w[i];
	}
	int mx = 0;
	for(int j = 1;j<=n;j++){
		if(b[j]>=0) mx+=b[j];
	}
	int maxn = 0;
	for(int i = 1;i<=m;i++){
		maxn = max(maxn,s[i]+mx);
	}
	cout<<maxn<<endl;
	
	return 0;
}

Submission Info

Submission Time
Task C - Buy Balls
User ruixi0528
Language C++ 20 (gcc 12.2)
Score 0
Code Size 692 Byte
Status WA
Exec Time 60 ms
Memory 8328 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 1
WA × 2
AC × 21
WA × 28
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3520 KB
00_sample_01.txt WA 1 ms 3520 KB
00_sample_02.txt WA 1 ms 3524 KB
01_test_00.txt AC 1 ms 3520 KB
01_test_01.txt AC 1 ms 3644 KB
01_test_02.txt AC 1 ms 3524 KB
01_test_03.txt WA 30 ms 5924 KB
01_test_04.txt AC 21 ms 4756 KB
01_test_05.txt AC 18 ms 4664 KB
01_test_06.txt AC 58 ms 8104 KB
01_test_07.txt AC 58 ms 8204 KB
01_test_08.txt WA 60 ms 8072 KB
01_test_09.txt AC 58 ms 8152 KB
01_test_10.txt WA 58 ms 8204 KB
01_test_11.txt AC 59 ms 8200 KB
01_test_12.txt AC 58 ms 8328 KB
01_test_13.txt AC 59 ms 8204 KB
01_test_14.txt AC 58 ms 8132 KB
01_test_15.txt WA 51 ms 7724 KB
01_test_16.txt WA 57 ms 8172 KB
01_test_17.txt WA 49 ms 7712 KB
01_test_18.txt WA 58 ms 8328 KB
01_test_19.txt WA 52 ms 7872 KB
01_test_20.txt WA 57 ms 8296 KB
01_test_21.txt WA 49 ms 7800 KB
01_test_22.txt WA 57 ms 8204 KB
01_test_23.txt WA 46 ms 7568 KB
01_test_24.txt WA 58 ms 8140 KB
01_test_25.txt WA 46 ms 7332 KB
01_test_26.txt AC 58 ms 8104 KB
01_test_27.txt AC 49 ms 7488 KB
01_test_28.txt AC 58 ms 8064 KB
01_test_29.txt WA 47 ms 7468 KB
01_test_30.txt WA 57 ms 8104 KB
01_test_31.txt WA 40 ms 6792 KB
01_test_32.txt WA 57 ms 8204 KB
01_test_33.txt WA 44 ms 7588 KB
01_test_34.txt AC 54 ms 8144 KB
01_test_35.txt WA 45 ms 7276 KB
01_test_36.txt WA 55 ms 8104 KB
01_test_37.txt WA 38 ms 6716 KB
01_test_38.txt WA 57 ms 8324 KB
01_test_39.txt WA 41 ms 7140 KB
01_test_40.txt WA 56 ms 8080 KB
01_test_41.txt AC 40 ms 7224 KB
01_test_42.txt AC 56 ms 8272 KB
01_test_43.txt AC 1 ms 3608 KB
01_test_44.txt WA 30 ms 6700 KB
01_test_45.txt AC 29 ms 5048 KB


2025-04-04 (Fri)
01:20:00 +00:00