Submission #641894

# Submission time Handle Problem Language Result Execution time Memory
641894 2022-09-17T18:59:29 Z Vanilla Catfish Farm (IOI22_fish) C++17
52 / 100
1000 ms 365364 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 3002;
int64 dp [maxn][maxn][2];
int64 mx [maxn];
int64 p [maxn][maxn];
int64 pref [maxn][maxn];
int64 suff [maxn][maxn];

int64 max_weights(int n, int m, vector<int> x, vector<int> y,
                      vector<int> w) {
  for (int i = 0; i < m; i++) {
    p[++x[i]][++y[i]] = w[i];
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= n; j++){
      p[i][j]+=p[i][j-1];
    }
  }
  for (int i = 1; i <= n; i++){
    for (int j = 0; j <= n; j++){
      dp[i][j][0] = suff[i-1][j] - p[i][j];
      dp[i][j][1] = max(mx[i-2] + p[i-1][j], pref[i-1][j] + p[i-1][j]);
      mx[i] = max({mx[i], dp[i][j][0], dp[i][j][1]});
      // for (int k = j; k <= n; k++){
      //   dp[i][j][0] = max(dp[i][j][0], max(dp[i-1][k][0], dp[i-1][k][1]) + p[i][k] - p[i][j]);
      // }
      // for (int k = 0; k <= j; k++){
      //   dp[i][j][1] = max(dp[i][j][1], dp[i-1][k][1] - p[i-1][k] + p[i-1][j]);
      // }
    }
    for (int j = 0; j <= n; j++){
      pref[i][j] = max((j != 0 ? pref[i][j - 1]: 0ll), dp[i][j][1] - p[i][j]);
    }
    for (int j = n; j >= 0; j--){
      suff[i][j] = max((j != n ? suff[i][j + 1] : 0ll), max(dp[i][j][0], dp[i][j][1]) + p[i + 1][j]);
    }
  }
  return mx[n];
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 120376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 1079 ms 118368 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1101 ms 111464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 2 ms 3540 KB Output is correct
10 Correct 5 ms 8648 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 5 ms 8608 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 4 ms 8660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 2 ms 3540 KB Output is correct
10 Correct 5 ms 8648 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 5 ms 8608 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 4 ms 8660 KB Output is correct
15 Correct 4 ms 8660 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 18 ms 9680 KB Output is correct
18 Correct 16 ms 9676 KB Output is correct
19 Correct 15 ms 9684 KB Output is correct
20 Correct 16 ms 9672 KB Output is correct
21 Correct 16 ms 9680 KB Output is correct
22 Correct 26 ms 10712 KB Output is correct
23 Correct 7 ms 8916 KB Output is correct
24 Correct 12 ms 9304 KB Output is correct
25 Correct 5 ms 8660 KB Output is correct
26 Correct 7 ms 8788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 2 ms 3540 KB Output is correct
10 Correct 5 ms 8648 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 5 ms 8608 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 4 ms 8660 KB Output is correct
15 Correct 4 ms 8660 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 18 ms 9680 KB Output is correct
18 Correct 16 ms 9676 KB Output is correct
19 Correct 15 ms 9684 KB Output is correct
20 Correct 16 ms 9672 KB Output is correct
21 Correct 16 ms 9680 KB Output is correct
22 Correct 26 ms 10712 KB Output is correct
23 Correct 7 ms 8916 KB Output is correct
24 Correct 12 ms 9304 KB Output is correct
25 Correct 5 ms 8660 KB Output is correct
26 Correct 7 ms 8788 KB Output is correct
27 Correct 210 ms 352892 KB Output is correct
28 Correct 71 ms 43096 KB Output is correct
29 Correct 284 ms 365364 KB Output is correct
30 Correct 283 ms 365288 KB Output is correct
31 Correct 291 ms 365296 KB Output is correct
32 Correct 84 ms 32716 KB Output is correct
33 Correct 290 ms 365292 KB Output is correct
34 Correct 280 ms 364644 KB Output is correct
35 Correct 235 ms 356896 KB Output is correct
36 Correct 281 ms 363184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1101 ms 111464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 120376 KB Time limit exceeded
2 Halted 0 ms 0 KB -