답안 #1112375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112375 2024-11-14T06:54:48 Z JelalTkm Bigger segments (IZhO19_segments) C++17
27 / 100
1500 ms 70984 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define int long long int

const int N = 3e5 + 10;
const int md = 1e9 + 7;
const int INF = 1e18;

int32_t main(int32_t argc, char *argv[]) {

  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int T = 1;
  // cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n + 1), pref(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      pref[i] = pref[i - 1] + a[i];
    }

    vector<vector<int>> dp(n + 1, vector<int> (n + 1, INF));
    dp[0][0] = 0;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
      dp[i][1] = pref[i];
      for (int j = 2; j <= i; j++) {
        for (int k = i - 1; k >= 1; k--) {
          if (dp[k][j - 1] <= pref[i] - pref[k]) {
            dp[i][j] = pref[i] - pref[k];
            break;
          }
        }

        if (i == n && dp[i][j] != INF)
          ans = max(ans, j);
      }
    }

    cout << ans << '\n';
  }

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 38 ms 2384 KB Output is correct
17 Correct 37 ms 2384 KB Output is correct
18 Correct 32 ms 2384 KB Output is correct
19 Correct 16 ms 2556 KB Output is correct
20 Correct 3 ms 2384 KB Output is correct
21 Correct 35 ms 2460 KB Output is correct
22 Correct 16 ms 1616 KB Output is correct
23 Correct 7 ms 1104 KB Output is correct
24 Correct 34 ms 2384 KB Output is correct
25 Correct 45 ms 2552 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 30 ms 2448 KB Output is correct
28 Correct 35 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 8 ms 2428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 38 ms 2384 KB Output is correct
17 Correct 37 ms 2384 KB Output is correct
18 Correct 32 ms 2384 KB Output is correct
19 Correct 16 ms 2556 KB Output is correct
20 Correct 3 ms 2384 KB Output is correct
21 Correct 35 ms 2460 KB Output is correct
22 Correct 16 ms 1616 KB Output is correct
23 Correct 7 ms 1104 KB Output is correct
24 Correct 34 ms 2384 KB Output is correct
25 Correct 45 ms 2552 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 30 ms 2448 KB Output is correct
28 Correct 35 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 8 ms 2428 KB Output is correct
31 Execution timed out 1562 ms 70984 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 38 ms 2384 KB Output is correct
17 Correct 37 ms 2384 KB Output is correct
18 Correct 32 ms 2384 KB Output is correct
19 Correct 16 ms 2556 KB Output is correct
20 Correct 3 ms 2384 KB Output is correct
21 Correct 35 ms 2460 KB Output is correct
22 Correct 16 ms 1616 KB Output is correct
23 Correct 7 ms 1104 KB Output is correct
24 Correct 34 ms 2384 KB Output is correct
25 Correct 45 ms 2552 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 30 ms 2448 KB Output is correct
28 Correct 35 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 8 ms 2428 KB Output is correct
31 Execution timed out 1562 ms 70984 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 38 ms 2384 KB Output is correct
17 Correct 37 ms 2384 KB Output is correct
18 Correct 32 ms 2384 KB Output is correct
19 Correct 16 ms 2556 KB Output is correct
20 Correct 3 ms 2384 KB Output is correct
21 Correct 35 ms 2460 KB Output is correct
22 Correct 16 ms 1616 KB Output is correct
23 Correct 7 ms 1104 KB Output is correct
24 Correct 34 ms 2384 KB Output is correct
25 Correct 45 ms 2552 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 30 ms 2448 KB Output is correct
28 Correct 35 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 8 ms 2428 KB Output is correct
31 Execution timed out 1562 ms 70984 KB Time limit exceeded
32 Halted 0 ms 0 KB -