답안 #399588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
399588 2021-05-06T08:05:17 Z fedoseevtimofey Cigle (COI21_cigle) C++14
48 / 100
1000 ms 139584 KB
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>
#include <chrono>
 
using namespace std;
 
typedef long long ll;
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];
  vector <ll> pref(n + 1);
  for (int i = 0; i < n; ++i) {
    pref[i + 1] = pref[i] + d[i];
  }
  vector <vector <pair <int, int>>> go(n);
  for (int i = 0; i + 1 < n; ++i) {
    int r = 0;
    for (int l = 1; l <= i + 1; ++l) {
      while (r <= n - i - 1 && pref[i + 1] - pref[i + 1 - l] > pref[i + r + 1] - pref[i + 1]) ++r;
      if (pref[i + 1] - pref[i + 1 - l] == pref[i + r + 1] - pref[i + 1]) {
        go[i].push_back({l, r});
      }
    }
  }
  vector <vector <int>> dp(n + 1, vector <int> (n + 1));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      int uk = 0;
      for (int k = 1; k + i <= n; ++k) { 
        while (uk < go[i - 1].size() && j > go[i - 1][uk].first && k > go[i - 1][uk].second) ++uk;
        dp[i + k][k] = max(dp[i + k][k], dp[i][j] + uk);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << '\n';
}

Compilation message

cigle.cpp: In function 'int main()':
cigle.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         while (uk < go[i - 1].size() && j > go[i - 1][uk].first && k > go[i - 1][uk].second) ++uk;
      |                ~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 236 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 236 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 1612 KB Output is correct
2 Correct 86 ms 1868 KB Output is correct
3 Correct 93 ms 1740 KB Output is correct
4 Correct 96 ms 1776 KB Output is correct
5 Correct 92 ms 1740 KB Output is correct
6 Correct 113 ms 1724 KB Output is correct
7 Correct 112 ms 1804 KB Output is correct
8 Correct 111 ms 1740 KB Output is correct
9 Correct 112 ms 1800 KB Output is correct
10 Correct 98 ms 1748 KB Output is correct
11 Correct 102 ms 1740 KB Output is correct
12 Correct 98 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 236 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 84 ms 1612 KB Output is correct
22 Correct 86 ms 1868 KB Output is correct
23 Correct 93 ms 1740 KB Output is correct
24 Correct 96 ms 1776 KB Output is correct
25 Correct 92 ms 1740 KB Output is correct
26 Correct 113 ms 1724 KB Output is correct
27 Correct 112 ms 1804 KB Output is correct
28 Correct 111 ms 1740 KB Output is correct
29 Correct 112 ms 1800 KB Output is correct
30 Correct 98 ms 1748 KB Output is correct
31 Correct 102 ms 1740 KB Output is correct
32 Correct 98 ms 1612 KB Output is correct
33 Correct 84 ms 1664 KB Output is correct
34 Correct 84 ms 1740 KB Output is correct
35 Correct 87 ms 1732 KB Output is correct
36 Correct 86 ms 1720 KB Output is correct
37 Correct 110 ms 1800 KB Output is correct
38 Correct 125 ms 1792 KB Output is correct
39 Correct 101 ms 1356 KB Output is correct
40 Correct 79 ms 1320 KB Output is correct
41 Correct 80 ms 1332 KB Output is correct
42 Correct 81 ms 1356 KB Output is correct
43 Correct 83 ms 1348 KB Output is correct
44 Correct 80 ms 1228 KB Output is correct
45 Correct 80 ms 1228 KB Output is correct
46 Correct 80 ms 1336 KB Output is correct
47 Correct 80 ms 1228 KB Output is correct
48 Correct 85 ms 1348 KB Output is correct
49 Correct 81 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 236 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 84 ms 1612 KB Output is correct
22 Correct 86 ms 1868 KB Output is correct
23 Correct 93 ms 1740 KB Output is correct
24 Correct 96 ms 1776 KB Output is correct
25 Correct 92 ms 1740 KB Output is correct
26 Correct 113 ms 1724 KB Output is correct
27 Correct 112 ms 1804 KB Output is correct
28 Correct 111 ms 1740 KB Output is correct
29 Correct 112 ms 1800 KB Output is correct
30 Correct 98 ms 1748 KB Output is correct
31 Correct 102 ms 1740 KB Output is correct
32 Correct 98 ms 1612 KB Output is correct
33 Correct 84 ms 1664 KB Output is correct
34 Correct 84 ms 1740 KB Output is correct
35 Correct 87 ms 1732 KB Output is correct
36 Correct 86 ms 1720 KB Output is correct
37 Correct 110 ms 1800 KB Output is correct
38 Correct 125 ms 1792 KB Output is correct
39 Correct 101 ms 1356 KB Output is correct
40 Correct 79 ms 1320 KB Output is correct
41 Correct 80 ms 1332 KB Output is correct
42 Correct 81 ms 1356 KB Output is correct
43 Correct 83 ms 1348 KB Output is correct
44 Correct 80 ms 1228 KB Output is correct
45 Correct 80 ms 1228 KB Output is correct
46 Correct 80 ms 1336 KB Output is correct
47 Correct 80 ms 1228 KB Output is correct
48 Correct 85 ms 1348 KB Output is correct
49 Correct 81 ms 1228 KB Output is correct
50 Execution timed out 1086 ms 139584 KB Time limit exceeded
51 Halted 0 ms 0 KB -