# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
531308 |
2022-02-28T11:28:31 Z |
Alan |
Raisins (IOI09_raisins) |
C++17 |
|
5000 ms |
336 KB |
#include <bits/stdc++.h>
#define I using
#define WA using namespace std;
#define on using ll = long long;
#define Test(x) int AlanIQ = -(x);
#define should ld =
#define quit long double;
#define OI int
#define forever main
#define Alan cin.tie(0);
#define fai(x) ios::ios_base::sync_with_stdio(!x);
#define Sharky return
#define orz 0;
WA on Test (109)
int dp[51][51][2], a[51][51], ps[51][51];
bool calc[51][51][2];
int n, m;
int solve (int i, int j, bool mode) {
if (i == j) return 0;
if (calc[i][j][mode]) return dp[i][j][mode];
dp[i][j][mode] = min(dp[i][j][mode], min(solve(i, j-1, mode), solve(i+1, j, mode)) + (mode ? ps[j][m]-ps[i-1][m] : ps[n][j]-ps[n][i-1]));
return dp[i][j][mode];
}
I should quit OI forever () {
Alan fai (true)
cin >> n >> m;
for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) for (int k = 0; k < 2; k++) dp[i][j][k] = 1e9;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
ps[i][j] = a[i][j] + ps[i][j-1] + ps[i-1][j] - ps[i-1][j-1];
}
}
int ans = solve(1, m, 0);
cout << ans + solve(1, n, 1) << "\n";
Sharky orz
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
8 |
Incorrect |
35 ms |
332 KB |
Output isn't correct |
9 |
Incorrect |
88 ms |
336 KB |
Output isn't correct |
10 |
Incorrect |
283 ms |
336 KB |
Output isn't correct |
11 |
Incorrect |
2220 ms |
336 KB |
Output isn't correct |
12 |
Execution timed out |
5009 ms |
324 KB |
Time limit exceeded |
13 |
Execution timed out |
5091 ms |
308 KB |
Time limit exceeded |
14 |
Execution timed out |
5040 ms |
316 KB |
Time limit exceeded |
15 |
Execution timed out |
5004 ms |
304 KB |
Time limit exceeded |
16 |
Execution timed out |
5042 ms |
324 KB |
Time limit exceeded |
17 |
Execution timed out |
5031 ms |
324 KB |
Time limit exceeded |
18 |
Execution timed out |
5061 ms |
332 KB |
Time limit exceeded |
19 |
Execution timed out |
5044 ms |
332 KB |
Time limit exceeded |
20 |
Execution timed out |
5058 ms |
332 KB |
Time limit exceeded |