# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
666643 |
2022-11-29T08:18:16 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=1;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++)
{
dp[i][j][0]=max(dp[i][j][0], dp[i-2][k][0]+pref[i-1][j]-pref[i-1][k]+pref[i+1][j]);
dp[i][j][0]=max(dp[i][j][0], dp[i-2][k][1]+pref[i-1][j]-pref[i-1][k]+pref[i+1][j]);
dp[i][j][1]=max(dp[i][j][1], dp[i][j][0]);
}
}
}
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 |
Execution timed out |
1209 ms |
1883656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
917 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
907 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Incorrect |
0 ms |
300 KB |
1st lines differ - on the 1st token, expected: '8866', found: '7755' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Incorrect |
0 ms |
300 KB |
1st lines differ - on the 1st token, expected: '8866', found: '7755' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Incorrect |
0 ms |
300 KB |
1st lines differ - on the 1st token, expected: '8866', found: '7755' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
907 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1209 ms |
1883656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |