Submission #231351

# Submission time Handle Problem Language Result Execution time Memory
231351 2020-05-13T11:52:13 Z maskoff Bigger segments (IZhO19_segments) C++14
37 / 100
1500 ms 3840 KB
#include <bits/stdc++.h>
#include <ext/rope>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
 
#define file ""
 
#define all(x) x.begin(), x.end()
 
#define sc second
#define fr first
 
#define pb push_back
#define mp make_pair

#define pss pair<line*, line*>
 
using namespace std;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef pair <int, int> pii;
                                    
const int inf = 1e9;
const int MOD = 1e9 + 7;
                                          
const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};

int const N = 5e5 + 1;

int main() {   
	ios_base :: sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n + 1), pref(n + 1);
  for (int i = 1; i <= n; i++)
  	cin >> a[i];
  for (int i = 1; i <= n; i++)
  	pref[i] = pref[i - 1] + a[i];
  vector<pair<ll, ll>> dp(n + 1);

  for (int i = 1; i <= n; i++) {
   	for (int j = 0; j < i; j++) {
   	 	if (pref[i] - pref[j] >= dp[j].sc) {
   	 		if (dp[j].fr + 1 >= dp[i].fr) {
   	 		 	dp[i].fr = dp[j].fr + 1;
   	 			dp[i].sc = pref[i] - pref[j];
   	 		}
   	 	}
   	}
  }
  /*for (int i = 1; i <= n; i++) {
   	cout << dp[i].fr << " " << dp[i].sc << endl;
  }              */
  cout << dp[n].fr;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 9 ms 384 KB Output is correct
32 Correct 12 ms 512 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 384 KB Output is correct
35 Correct 13 ms 512 KB Output is correct
36 Correct 13 ms 512 KB Output is correct
37 Correct 11 ms 384 KB Output is correct
38 Correct 8 ms 384 KB Output is correct
39 Correct 12 ms 384 KB Output is correct
40 Correct 13 ms 512 KB Output is correct
41 Correct 12 ms 384 KB Output is correct
42 Correct 12 ms 384 KB Output is correct
43 Correct 12 ms 384 KB Output is correct
44 Correct 14 ms 384 KB Output is correct
45 Correct 13 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 9 ms 384 KB Output is correct
32 Correct 12 ms 512 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 384 KB Output is correct
35 Correct 13 ms 512 KB Output is correct
36 Correct 13 ms 512 KB Output is correct
37 Correct 11 ms 384 KB Output is correct
38 Correct 8 ms 384 KB Output is correct
39 Correct 12 ms 384 KB Output is correct
40 Correct 13 ms 512 KB Output is correct
41 Correct 12 ms 384 KB Output is correct
42 Correct 12 ms 384 KB Output is correct
43 Correct 12 ms 384 KB Output is correct
44 Correct 14 ms 384 KB Output is correct
45 Correct 13 ms 384 KB Output is correct
46 Execution timed out 1591 ms 3840 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 9 ms 384 KB Output is correct
32 Correct 12 ms 512 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 384 KB Output is correct
35 Correct 13 ms 512 KB Output is correct
36 Correct 13 ms 512 KB Output is correct
37 Correct 11 ms 384 KB Output is correct
38 Correct 8 ms 384 KB Output is correct
39 Correct 12 ms 384 KB Output is correct
40 Correct 13 ms 512 KB Output is correct
41 Correct 12 ms 384 KB Output is correct
42 Correct 12 ms 384 KB Output is correct
43 Correct 12 ms 384 KB Output is correct
44 Correct 14 ms 384 KB Output is correct
45 Correct 13 ms 384 KB Output is correct
46 Execution timed out 1591 ms 3840 KB Time limit exceeded
47 Halted 0 ms 0 KB -