# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
666707 |
2022-11-29T11:59:20 Z |
Banan |
Catfish Farm (IOI22_fish) |
C++17 |
|
1000 ms |
2097152 KB |
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define double long double
#define endl '\n'
#define sz(a) (int)a.size()
#define pb push_back
#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
ll const INF = LONG_LONG_MAX;
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w)
{
vector<vector<ll>> val(n+5, vector<ll>(n+5, 0)), pref(n+5, vector<ll>(n+5, 0));
for(int i=0;i<m;i++)
{
val[x[i]+1][y[i]+1]=w[i];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
pref[i][j]=pref[i][j-1]+val[i][j];
}
}
vector<vector<vector<ll>>> dp(n+5, vector<vector<ll>>(n+5, vector<ll>(2, 0)));
for(int j=1;j<=n;j++)
{
dp[1][j][0]=dp[1][j-1][0]+val[2][j];
dp[1][j][1]=dp[1][j-1][1]+val[2][j];
}
for(int i=2;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
for(int k=1;k<=j;k++)
{
dp[i][j][0]=max(dp[i][j][0], dp[i-1][k][0]+pref[i-1][j]-pref[i-1][k]-pref[i][k]+pref[i+1][j]);
}
for(int k=n;k>=j;k--)
{
dp[i][j][1]=max(dp[i][j][1], dp[i-1][k][1]-pref[i][j]+pref[i+1][j]);
dp[i][j][1]=max(dp[i][j][1], dp[i-1][k][0]-pref[i][j]+pref[i+1][j]);
}
for(int k=0;k<=n;k++)
{
ll val=0;
if(k<=j)
{
val=max(val, dp[i-2][k][0]+pref[i-1][j]-pref[i-1][k]+pref[i+1][j]);
val=max(val, dp[i-2][k][1]+pref[i-1][j]-pref[i-1][k]+pref[i+1][j]);
}
else
{
val=max(val, dp[i-2][k][0]+pref[i+1][j]);
val=max(val, dp[i-2][k][1]+pref[i+1][j]);
}
dp[i][j][0]=max(dp[i][j][0], val);
dp[i][j][1]=max(dp[i][j][1], val);
}
}
}
// cout<<endl<<endl;
// for(int i=0;i<=n;i++)
// {
// for(int j=0;j<=n;j++)
// {
// cout<<dp[i][j][0]<<' ';
// }
// cout<<endl;
// }
// cout<<endl<<endl;
// for(int i=0;i<=n;i++)
// {
// for(int j=0;j<=n;j++)
// {
// cout<<dp[i][j][1]<<' ';
// }
// cout<<endl;
// }
// cout<<endl<<endl;
ll ans=0;
for(int i=0;i<=n;i++)
ans=max(ans, max(dp[n][i][0], dp[n][i][1]));
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
216 KB |
Output is correct |
2 |
Runtime error |
766 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
764 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
220 KB |
Output is correct |
2 |
Correct |
1 ms |
224 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
21 ms |
2004 KB |
Output is correct |
10 |
Correct |
150 ms |
6868 KB |
Output is correct |
11 |
Correct |
20 ms |
2004 KB |
Output is correct |
12 |
Correct |
148 ms |
6868 KB |
Output is correct |
13 |
Correct |
4 ms |
684 KB |
Output is correct |
14 |
Correct |
145 ms |
6924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
220 KB |
Output is correct |
2 |
Correct |
1 ms |
224 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
21 ms |
2004 KB |
Output is correct |
10 |
Correct |
150 ms |
6868 KB |
Output is correct |
11 |
Correct |
20 ms |
2004 KB |
Output is correct |
12 |
Correct |
148 ms |
6868 KB |
Output is correct |
13 |
Correct |
4 ms |
684 KB |
Output is correct |
14 |
Correct |
145 ms |
6924 KB |
Output is correct |
15 |
Correct |
149 ms |
6884 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
154 ms |
8740 KB |
Output is correct |
18 |
Correct |
161 ms |
8724 KB |
Output is correct |
19 |
Correct |
164 ms |
8700 KB |
Output is correct |
20 |
Correct |
159 ms |
8636 KB |
Output is correct |
21 |
Correct |
153 ms |
8780 KB |
Output is correct |
22 |
Correct |
170 ms |
10664 KB |
Output is correct |
23 |
Correct |
145 ms |
7200 KB |
Output is correct |
24 |
Correct |
153 ms |
8084 KB |
Output is correct |
25 |
Correct |
146 ms |
6940 KB |
Output is correct |
26 |
Correct |
148 ms |
7124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
220 KB |
Output is correct |
2 |
Correct |
1 ms |
224 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
21 ms |
2004 KB |
Output is correct |
10 |
Correct |
150 ms |
6868 KB |
Output is correct |
11 |
Correct |
20 ms |
2004 KB |
Output is correct |
12 |
Correct |
148 ms |
6868 KB |
Output is correct |
13 |
Correct |
4 ms |
684 KB |
Output is correct |
14 |
Correct |
145 ms |
6924 KB |
Output is correct |
15 |
Correct |
149 ms |
6884 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
154 ms |
8740 KB |
Output is correct |
18 |
Correct |
161 ms |
8724 KB |
Output is correct |
19 |
Correct |
164 ms |
8700 KB |
Output is correct |
20 |
Correct |
159 ms |
8636 KB |
Output is correct |
21 |
Correct |
153 ms |
8780 KB |
Output is correct |
22 |
Correct |
170 ms |
10664 KB |
Output is correct |
23 |
Correct |
145 ms |
7200 KB |
Output is correct |
24 |
Correct |
153 ms |
8084 KB |
Output is correct |
25 |
Correct |
146 ms |
6940 KB |
Output is correct |
26 |
Correct |
148 ms |
7124 KB |
Output is correct |
27 |
Execution timed out |
1115 ms |
636936 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
764 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
743 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |