# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
912774 |
2024-01-19T22:02:36 Z |
biank |
Catfish Farm (IOI22_fish) |
C++17 |
|
76 ms |
13924 KB |
#include <bits/stdc++.h>
//#include "fish.h"
using namespace std;
#define ALL(x) x.begin(),x.end()
#define SIZE(x) (int)x.size()
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define fst first
#define snd second
#define pb push_back
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<int> vi;
const ll INF = 1e18;
ll subtask1(vi &w) {
ll ans=0;
forn(i,SIZE(w)) ans+=w[i];
return ans;
}
ll subtask2(int n, vi &x, vi &y, vi &w) {
if(n==1) return 0;
if(n==2) {
ll sum[2]={0,0};
forn(i,SIZE(w)) sum[x[i]]+=w[i];
return max(sum[0],sum[1]);
}
int m=SIZE(x);
ll sum=0;
forn(i,m) if(x[i]==1) sum+=w[i];
ll val[2]={0,0},ans=sum;
vii p(m);
forn(i,n) p[i]={y[i],x[i]};
sort(ALL(p));
forn(i,m) {
val[p[i].snd]+=w[i];
ans=max(ans,val[0]+sum-val[1]);
}
return ans;
}
ll subtask3(int n, vi &x, vi &w) {
int m=SIZE(w);
vi val(n+1,0);
forn(i,m) val[x[i]+1]+=w[i];
vector<ll> dp1(n+2), dp2(n+2);
dp2[0]=dp2[1]=-INF;
forn(i,n) {
dp1[i+2]=max(dp1[i+1],dp2[i+1]+val[i+1]);
dp2[i+2]=max(dp2[i+1],max(dp1[i],dp2[i])+val[i]);
}
return max(dp1[n+1], dp2[n+1]);
}
ll max_weights(int n, int m, vi x, vi y, vi w) {
bool s1=true;
forn(i,m) s1&=(x[i]&1)==0;
if(s1) return subtask1(w);
bool s2=true;
forn(i,m) s2&=x[i]==0||x[i]==1;
if(s2) return subtask2(n,x,y,w);
bool s3=true;
forn(i,m) s3&=y[i]==0;
if(s3) return subtask3(n,x,w);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3712 KB |
Output is correct |
2 |
Correct |
23 ms |
4296 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
76 ms |
13796 KB |
Output is correct |
6 |
Correct |
73 ms |
13924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
51 ms |
8336 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '76506574617169' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
14 ms |
4188 KB |
Output is correct |
4 |
Correct |
11 ms |
3676 KB |
Output is correct |
5 |
Correct |
28 ms |
6336 KB |
Output is correct |
6 |
Correct |
21 ms |
5724 KB |
Output is correct |
7 |
Correct |
30 ms |
6328 KB |
Output is correct |
8 |
Correct |
33 ms |
6088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
14 ms |
4188 KB |
Output is correct |
4 |
Correct |
11 ms |
3676 KB |
Output is correct |
5 |
Correct |
28 ms |
6336 KB |
Output is correct |
6 |
Correct |
21 ms |
5724 KB |
Output is correct |
7 |
Correct |
30 ms |
6328 KB |
Output is correct |
8 |
Correct |
33 ms |
6088 KB |
Output is correct |
9 |
Incorrect |
21 ms |
4036 KB |
1st lines differ - on the 1st token, expected: '99999', found: '0' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3712 KB |
Output is correct |
2 |
Correct |
23 ms |
4296 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
76 ms |
13796 KB |
Output is correct |
6 |
Correct |
73 ms |
13924 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
51 ms |
8336 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '76506574617169' |
9 |
Halted |
0 ms |
0 KB |
- |