답안 #654761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654761 2022-11-01T14:14:56 Z t6twotwo 메기 농장 (IOI22_fish) C++17
35 / 100
1000 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const long long inf = -(1LL << 60);
long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
  vector p(n, vector<int>(n + 1));
  for (int i = 0; i < m; i++) {
    p[x[i]][y[i] + 1] = w[i];
  }
  vector s(n, vector<long long>(n + 2));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      s[i][j + 1] = s[i][j] + p[i][j];
    }
  }
  auto range_sum = [&](int i, int l, int r) -> long long {
    if (i == -1) {
      return 0;
    }
    return s[i][r + 1] - s[i][l + 1];
  };
  vector dp(n + 1, array<long long, 2>{inf, inf});
  dp[0] = {0, 0};
  for (int i = 0; i < n; i++) {
    auto pd = dp;
    dp = vector(n + 1, array<long long, 2>{inf, inf});
    for (int j = 0; j <= n; j++) {
      dp[0][0] = max(dp[0][0], max(pd[j][0], pd[j][1]));
      dp[0][1] = max(dp[0][1], max(pd[j][0], pd[j][1]) + range_sum(i, 0, j));
    }
    for (int j = 1; j <= n; j++) {
      dp[j][0] = max(dp[j][0], max(pd[0][1], pd[0][0] + range_sum(i - 1, 0, j)));
      dp[j][1] = max(dp[j][1], max(pd[0][1], pd[0][0] + range_sum(i - 1, 0, j)));
      for (int k = 1; k <= j; k++) {
        dp[j][0] = max(dp[j][0], pd[k][0] + range_sum(i - 1, k, j));
      }
      for (int k = j; k <= n; k++) {
        dp[j][1] = max(dp[j][1], max(pd[k][0], pd[k][1]) + range_sum(i, j, k));
      }
    }
  }
  long long ans = inf;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, max(dp[i][0], dp[i][1]));
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 798 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1133 ms 1937648 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 785 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 224 KB Output is correct
6 Correct 1 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 7 ms 492 KB Output is correct
10 Correct 36 ms 1364 KB Output is correct
11 Correct 7 ms 596 KB Output is correct
12 Correct 39 ms 1364 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 44 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 224 KB Output is correct
6 Correct 1 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 7 ms 492 KB Output is correct
10 Correct 36 ms 1364 KB Output is correct
11 Correct 7 ms 596 KB Output is correct
12 Correct 39 ms 1364 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 44 ms 1368 KB Output is correct
15 Correct 37 ms 1452 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 52 ms 3008 KB Output is correct
18 Correct 51 ms 3092 KB Output is correct
19 Correct 48 ms 3096 KB Output is correct
20 Correct 50 ms 3080 KB Output is correct
21 Correct 65 ms 3060 KB Output is correct
22 Correct 61 ms 4812 KB Output is correct
23 Correct 37 ms 1620 KB Output is correct
24 Correct 44 ms 2460 KB Output is correct
25 Correct 36 ms 1364 KB Output is correct
26 Correct 38 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 224 KB Output is correct
6 Correct 1 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 7 ms 492 KB Output is correct
10 Correct 36 ms 1364 KB Output is correct
11 Correct 7 ms 596 KB Output is correct
12 Correct 39 ms 1364 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 44 ms 1368 KB Output is correct
15 Correct 37 ms 1452 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 52 ms 3008 KB Output is correct
18 Correct 51 ms 3092 KB Output is correct
19 Correct 48 ms 3096 KB Output is correct
20 Correct 50 ms 3080 KB Output is correct
21 Correct 65 ms 3060 KB Output is correct
22 Correct 61 ms 4812 KB Output is correct
23 Correct 37 ms 1620 KB Output is correct
24 Correct 44 ms 2460 KB Output is correct
25 Correct 36 ms 1364 KB Output is correct
26 Correct 38 ms 1492 KB Output is correct
27 Execution timed out 1093 ms 106460 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 785 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 798 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -