#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct fish{fish(int xi,int yi,int wi):x(xi),y(yi),w(wi){} int x,y,w;};
ll max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W) {
if(N==2) {
ll c1=0,c2=0;
for(int i=0;i<M;++i) {
if(X[i]==0) c1+=W[i];
else c2+=W[i];
}
return max(c1,c2);
} else {
vector<fish> v;
ll tot=0;
for(int i=0;i<M;++i) {
v.push_back(fish(X[i],Y[i],W[i]));
if(X[i]==1) tot+=W[i];
}
ll ans=tot;
sort(v.begin(),v.end(),[](fish a,fish b) {return (a.y==b.y?a.x>b.x:a.y<b.y);});
for(fish f:v) {
if(f.x==1) tot-=f.w;
else tot+=f.w;
ans=max(ans,tot);
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
4056 KB |
Output is correct |
2 |
Correct |
40 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
125 ms |
14220 KB |
Output is correct |
6 |
Correct |
131 ms |
14032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
67 ms |
7516 KB |
Output is correct |
3 |
Correct |
84 ms |
8388 KB |
Output is correct |
4 |
Correct |
37 ms |
4108 KB |
Output is correct |
5 |
Correct |
38 ms |
4544 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
30 ms |
4084 KB |
Output is correct |
13 |
Correct |
37 ms |
4532 KB |
Output is correct |
14 |
Correct |
33 ms |
4036 KB |
Output is correct |
15 |
Correct |
37 ms |
4312 KB |
Output is correct |
16 |
Correct |
32 ms |
4140 KB |
Output is correct |
17 |
Correct |
35 ms |
4232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Incorrect |
20 ms |
2656 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Incorrect |
20 ms |
2656 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
4056 KB |
Output is correct |
2 |
Correct |
40 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
125 ms |
14220 KB |
Output is correct |
6 |
Correct |
131 ms |
14032 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
67 ms |
7516 KB |
Output is correct |
9 |
Correct |
84 ms |
8388 KB |
Output is correct |
10 |
Correct |
37 ms |
4108 KB |
Output is correct |
11 |
Correct |
38 ms |
4544 KB |
Output is correct |
12 |
Correct |
1 ms |
308 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
30 ms |
4084 KB |
Output is correct |
19 |
Correct |
37 ms |
4532 KB |
Output is correct |
20 |
Correct |
33 ms |
4036 KB |
Output is correct |
21 |
Correct |
37 ms |
4312 KB |
Output is correct |
22 |
Correct |
32 ms |
4140 KB |
Output is correct |
23 |
Correct |
35 ms |
4232 KB |
Output is correct |
24 |
Correct |
1 ms |
296 KB |
Output is correct |
25 |
Correct |
1 ms |
304 KB |
Output is correct |
26 |
Incorrect |
20 ms |
2656 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
27 |
Halted |
0 ms |
0 KB |
- |