#include "fish.h"
#include <iostream>
#include <vector>
#include <tuple>
#include <set>
#include <algorithm>
#include <map>
using namespace std;
#define ff first
#define ss second
#define ll long long
int n,m;
vector<int>x,y,w;
ll ans=0;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
tie(n,m,x,y,w)=tie(N,M,X,Y,W);
bool su1=true,su2=true;
for(int i=0;i<m;i++){
if(x[i]%2==1) su1=false;
if(x[i]>1) su2=false;
}
if(su1){for(int i=0;i<m;i++) ans+=w[i];return ans;}
if(su2){
ll cur=0;
if(n==2){
for(int i=0;i<m;i++){
if(x[i]) cur+=w[i];
else ans+=w[i];
}
return max(ans,cur);
}
vector<pair<int,int>>a,b;
for(int i=0;i<m;i++){
if(x[i]&1) cur+=w[i],a.push_back({y[i],w[i]});
else b.push_back({y[i],w[i]});
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
ans=cur;
int j=0;
for(auto [g,f]:b){
cur+=f;
while(j<a.size() && a[j].ff<=g) cur-=a[j].ss,j++;
ans=max(ans,cur);
}
return ans;
}
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:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | while(j<a.size() && a[j].ff<=g) cur-=a[j].ss,j++;
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
3164 KB |
Output is correct |
2 |
Correct |
18 ms |
3924 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
53 ms |
10868 KB |
Output is correct |
6 |
Correct |
55 ms |
10832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
40 ms |
7632 KB |
Output is correct |
3 |
Correct |
54 ms |
9160 KB |
Output is correct |
4 |
Correct |
17 ms |
3156 KB |
Output is correct |
5 |
Correct |
17 ms |
3928 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
30 ms |
5836 KB |
Output is correct |
13 |
Correct |
26 ms |
6860 KB |
Output is correct |
14 |
Correct |
21 ms |
5488 KB |
Output is correct |
15 |
Correct |
24 ms |
6228 KB |
Output is correct |
16 |
Correct |
29 ms |
5612 KB |
Output is correct |
17 |
Correct |
24 ms |
6096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
3164 KB |
Output is correct |
2 |
Correct |
18 ms |
3924 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
53 ms |
10868 KB |
Output is correct |
6 |
Correct |
55 ms |
10832 KB |
Output is correct |
7 |
Correct |
0 ms |
596 KB |
Output is correct |
8 |
Correct |
40 ms |
7632 KB |
Output is correct |
9 |
Correct |
54 ms |
9160 KB |
Output is correct |
10 |
Correct |
17 ms |
3156 KB |
Output is correct |
11 |
Correct |
17 ms |
3928 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
30 ms |
5836 KB |
Output is correct |
19 |
Correct |
26 ms |
6860 KB |
Output is correct |
20 |
Correct |
21 ms |
5488 KB |
Output is correct |
21 |
Correct |
24 ms |
6228 KB |
Output is correct |
22 |
Correct |
29 ms |
5612 KB |
Output is correct |
23 |
Correct |
24 ms |
6096 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
26 |
Halted |
0 ms |
0 KB |
- |