# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
912778 |
2024-01-19T22:09:11 Z |
biank |
Catfish Farm (IOI22_fish) |
C++17 |
|
77 ms |
10188 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;
typedef vector<ll> vll;
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]);
}
vll val[2];
forn(i,2) val[i]=vll(n+1,0);
forn(i,SIZE(w)) val[x[i]][y[i]+1]+=w[i];
forn(i,n) val[0][i+1]+=val[0][i], val[1][i+1]+=val[1][i];
ll ans=0;
forn(i,n+1) ans=max(ans,val[0][i]+val[1][n]-val[1][i]);
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];
vll 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 |
18 ms |
2136 KB |
Output is correct |
2 |
Correct |
22 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
72 ms |
7288 KB |
Output is correct |
6 |
Correct |
77 ms |
7248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
38 ms |
5424 KB |
Output is correct |
3 |
Correct |
47 ms |
10188 KB |
Output is correct |
4 |
Correct |
18 ms |
3672 KB |
Output is correct |
5 |
Correct |
23 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
20 ms |
4956 KB |
Output is correct |
13 |
Correct |
24 ms |
6092 KB |
Output is correct |
14 |
Correct |
20 ms |
4944 KB |
Output is correct |
15 |
Correct |
22 ms |
5912 KB |
Output is correct |
16 |
Correct |
21 ms |
5060 KB |
Output is correct |
17 |
Correct |
24 ms |
5580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
17 ms |
3416 KB |
Output is correct |
4 |
Correct |
10 ms |
3164 KB |
Output is correct |
5 |
Correct |
24 ms |
4692 KB |
Output is correct |
6 |
Correct |
21 ms |
4700 KB |
Output is correct |
7 |
Correct |
23 ms |
4700 KB |
Output is correct |
8 |
Correct |
23 ms |
4688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 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 |
1 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
17 ms |
3416 KB |
Output is correct |
4 |
Correct |
10 ms |
3164 KB |
Output is correct |
5 |
Correct |
24 ms |
4692 KB |
Output is correct |
6 |
Correct |
21 ms |
4700 KB |
Output is correct |
7 |
Correct |
23 ms |
4700 KB |
Output is correct |
8 |
Correct |
23 ms |
4688 KB |
Output is correct |
9 |
Incorrect |
20 ms |
2632 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 |
18 ms |
2136 KB |
Output is correct |
2 |
Correct |
22 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
72 ms |
7288 KB |
Output is correct |
6 |
Correct |
77 ms |
7248 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
38 ms |
5424 KB |
Output is correct |
9 |
Correct |
47 ms |
10188 KB |
Output is correct |
10 |
Correct |
18 ms |
3672 KB |
Output is correct |
11 |
Correct |
23 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
20 ms |
4956 KB |
Output is correct |
19 |
Correct |
24 ms |
6092 KB |
Output is correct |
20 |
Correct |
20 ms |
4944 KB |
Output is correct |
21 |
Correct |
22 ms |
5912 KB |
Output is correct |
22 |
Correct |
21 ms |
5060 KB |
Output is correct |
23 |
Correct |
24 ms |
5580 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
17 ms |
3416 KB |
Output is correct |
27 |
Correct |
10 ms |
3164 KB |
Output is correct |
28 |
Correct |
24 ms |
4692 KB |
Output is correct |
29 |
Correct |
21 ms |
4700 KB |
Output is correct |
30 |
Correct |
23 ms |
4700 KB |
Output is correct |
31 |
Correct |
23 ms |
4688 KB |
Output is correct |
32 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
33 |
Halted |
0 ms |
0 KB |
- |