답안 #1079509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079509 2024-08-28T16:10:44 Z ArthuroWich 메기 농장 (IOI22_fish) C++17
52 / 100
874 ms 2097152 KB
#include "fish.h"
// not my code, to test
#include <climits>

#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
  std::vector<std::vector<long long>> fish(N + 2, std::vector<long long>(N + 1));
  for (int i = 0; i < M; ++i) {
    fish[X[i] + 1][Y[i] + 1] = W[i];
  }

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      fish[i][j] += fish[i][j - 1];
    }
  }

  std::vector<long long> dpInc(N + 1, -1e18), dpDec(N + 1, -1e18);
  std::vector<long long> ndpInc(N + 1), ndpDec(N + 1);
  dpInc[0] = dpDec[0] = 0;
  for (int i = 1; i <= N + 1; ++i) {
    long long pref = 0LL;
    for (int j = 0; j <= N; ++j) {
      pref = std::max(pref, dpInc[j] - fish[i - 1][j]);
      ndpInc[j] = std::max(pref + fish[i - 1][j], dpDec[0]);
    }

    long long suff = 0LL;
    for (int j = N; j >= 0; --j) {
      suff = std::max(suff, std::max(dpInc[j], dpDec[j]) + fish[i][j]);
      ndpDec[j] = suff - fish[i][j];
    }

    std::swap(dpInc, ndpInc); std::swap(dpDec, ndpDec);
  }
  return std::max(dpInc[0], dpDec[0]);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 868 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 866 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 874 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 9 ms 2964 KB Output is correct
18 Correct 10 ms 2868 KB Output is correct
19 Correct 10 ms 2908 KB Output is correct
20 Correct 9 ms 2908 KB Output is correct
21 Correct 9 ms 2908 KB Output is correct
22 Correct 17 ms 4700 KB Output is correct
23 Correct 3 ms 1372 KB Output is correct
24 Correct 6 ms 2140 KB Output is correct
25 Correct 1 ms 944 KB Output is correct
26 Correct 3 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 9 ms 2964 KB Output is correct
18 Correct 10 ms 2868 KB Output is correct
19 Correct 10 ms 2908 KB Output is correct
20 Correct 9 ms 2908 KB Output is correct
21 Correct 9 ms 2908 KB Output is correct
22 Correct 17 ms 4700 KB Output is correct
23 Correct 3 ms 1372 KB Output is correct
24 Correct 6 ms 2140 KB Output is correct
25 Correct 1 ms 944 KB Output is correct
26 Correct 3 ms 1368 KB Output is correct
27 Correct 57 ms 71204 KB Output is correct
28 Correct 47 ms 13692 KB Output is correct
29 Correct 130 ms 83536 KB Output is correct
30 Correct 124 ms 83536 KB Output is correct
31 Correct 122 ms 83536 KB Output is correct
32 Correct 53 ms 14928 KB Output is correct
33 Correct 121 ms 83676 KB Output is correct
34 Correct 125 ms 83732 KB Output is correct
35 Correct 84 ms 75740 KB Output is correct
36 Correct 123 ms 83536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 874 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 868 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -