#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){
vector<pair<int,int>>a,b;
ll cur=0;
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:41: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]
41 | 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 |
17 ms |
3928 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
54 ms |
10856 KB |
Output is correct |
6 |
Correct |
54 ms |
10832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
51 ms |
7624 KB |
Output is correct |
3 |
Correct |
54 ms |
12740 KB |
Output is correct |
4 |
Correct |
16 ms |
4444 KB |
Output is correct |
5 |
Correct |
18 ms |
5584 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
17 ms |
3928 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
54 ms |
10856 KB |
Output is correct |
6 |
Correct |
54 ms |
10832 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
51 ms |
7624 KB |
Output is correct |
9 |
Correct |
54 ms |
12740 KB |
Output is correct |
10 |
Correct |
16 ms |
4444 KB |
Output is correct |
11 |
Correct |
18 ms |
5584 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
13 |
Halted |
0 ms |
0 KB |
- |