Submission #1057401

# Submission time Handle Problem Language Result Execution time Memory
1057401 2024-08-13T18:47:09 Z juicy 스트랩 (JOI14_straps) C++17
100 / 100
12 ms 32088 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 2e3 + 5;
const long long inf = 1e18;

int n;
long long dp[N][N];
array<int, 2> a[N];

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i][0] >> a[i][1];
  }
  sort(a + 1, a + n + 1, [&](const auto &a, const auto &b) {
    return a[0] > b[0];
  });
  for (int i = 0; i <= n; ++i) {
    fill(dp[i], dp[i] + n + 1, -inf);
  }
  dp[0][1] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (dp[i][j] != -inf) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        int k = min(n, j + a[i + 1][0] - 1);
        if (k >= 0) {
          dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][1]);
        }
      }
    }
  } 
  cout << *max_element(dp[n], dp[n] + n + 1);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2516 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2520 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 3 ms 16988 KB Output is correct
9 Correct 2 ms 16988 KB Output is correct
10 Correct 2 ms 16988 KB Output is correct
11 Correct 3 ms 16988 KB Output is correct
12 Correct 7 ms 31836 KB Output is correct
13 Correct 7 ms 31708 KB Output is correct
14 Correct 8 ms 31836 KB Output is correct
15 Correct 7 ms 31836 KB Output is correct
16 Correct 9 ms 31836 KB Output is correct
17 Correct 7 ms 31912 KB Output is correct
18 Correct 7 ms 31836 KB Output is correct
19 Correct 8 ms 31836 KB Output is correct
20 Correct 10 ms 31916 KB Output is correct
21 Correct 10 ms 31836 KB Output is correct
22 Correct 7 ms 31836 KB Output is correct
23 Correct 9 ms 31836 KB Output is correct
24 Correct 7 ms 31692 KB Output is correct
25 Correct 10 ms 31908 KB Output is correct
26 Correct 8 ms 31836 KB Output is correct
27 Correct 9 ms 31900 KB Output is correct
28 Correct 8 ms 31836 KB Output is correct
29 Correct 11 ms 31912 KB Output is correct
30 Correct 8 ms 32088 KB Output is correct
31 Correct 8 ms 31836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 2 ms 17020 KB Output is correct
10 Correct 2 ms 16988 KB Output is correct
11 Correct 2 ms 16988 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 16988 KB Output is correct
14 Correct 2 ms 17032 KB Output is correct
15 Correct 2 ms 16988 KB Output is correct
16 Correct 2 ms 16988 KB Output is correct
17 Correct 9 ms 31908 KB Output is correct
18 Correct 9 ms 31836 KB Output is correct
19 Correct 10 ms 31660 KB Output is correct
20 Correct 7 ms 31836 KB Output is correct
21 Correct 7 ms 31836 KB Output is correct
22 Correct 7 ms 31836 KB Output is correct
23 Correct 7 ms 31836 KB Output is correct
24 Correct 7 ms 31836 KB Output is correct
25 Correct 7 ms 31728 KB Output is correct
26 Correct 12 ms 31836 KB Output is correct
27 Correct 6 ms 31836 KB Output is correct
28 Correct 7 ms 31836 KB Output is correct
29 Correct 7 ms 31908 KB Output is correct
30 Correct 7 ms 31836 KB Output is correct
31 Correct 7 ms 31692 KB Output is correct
32 Correct 7 ms 31836 KB Output is correct
33 Correct 6 ms 31836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 31836 KB Output is correct
2 Correct 10 ms 31908 KB Output is correct
3 Correct 8 ms 31836 KB Output is correct
4 Correct 8 ms 31836 KB Output is correct
5 Correct 9 ms 31836 KB Output is correct
6 Correct 10 ms 31836 KB Output is correct
7 Correct 9 ms 31836 KB Output is correct
8 Correct 9 ms 31684 KB Output is correct
9 Correct 9 ms 31904 KB Output is correct
10 Correct 9 ms 31712 KB Output is correct
11 Correct 9 ms 31904 KB Output is correct
12 Correct 10 ms 31836 KB Output is correct
13 Correct 11 ms 31836 KB Output is correct
14 Correct 10 ms 31836 KB Output is correct
15 Correct 10 ms 31908 KB Output is correct
16 Correct 9 ms 31836 KB Output is correct
17 Correct 9 ms 31908 KB Output is correct
18 Correct 11 ms 31836 KB Output is correct
19 Correct 8 ms 31908 KB Output is correct
20 Correct 7 ms 31836 KB Output is correct
21 Correct 8 ms 31836 KB Output is correct
22 Correct 8 ms 31836 KB Output is correct
23 Correct 8 ms 31836 KB Output is correct
24 Correct 9 ms 31836 KB Output is correct
25 Correct 8 ms 31712 KB Output is correct