#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
ll max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
int even=0,X=0,Y=0;
for(int i=0;i<m;i++){
X=max(X,x[i]);
Y=max(Y,y[i]);
if(x[i]%2==0) even++;
}
if(even==m){
ll ans=0;
for(int i=0;i<m;i++){
ans+=w[i];
}
return ans;
}
if(X<=1){
ll ans=0,cur=0;
for(int i=0;i<m;i++){
if(x[i]==0){
ans+=w[i];
}
else{
cur+=w[i];
}
}
if(n==2) return max(ans,cur);
ll sum[n][2];
memset(sum,0,sizeof sum);
for(int i=0;i<m;i++){
sum[y[i]][x[i]]+=w[i];
}
ans=max(ans,cur);
for(int i=1;i<n;i++){
ans=max(ans,sum[i][0]+sum[n-1][1]-sum[i][1]);
}
return ans;
}
}
Compilation message
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
48 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
3664 KB |
Output is correct |
2 |
Correct |
22 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
68 ms |
13660 KB |
Output is correct |
6 |
Correct |
67 ms |
13960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
1884 KB |
Output is correct |
3 |
Incorrect |
13 ms |
3980 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
1884 KB |
Output is correct |
3 |
Incorrect |
13 ms |
3980 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
3664 KB |
Output is correct |
2 |
Correct |
22 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
68 ms |
13660 KB |
Output is correct |
6 |
Correct |
67 ms |
13960 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |