답안 #173365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173365 2020-01-03T20:02:47 Z Abelyan Bigger segments (IZhO19_segments) C++17
100 / 100
124 ms 24864 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
 
 
const int N=1e6+6;
const ll MOD=998244353;

ll dp1[N],dp2[N],a[N],pr[N],dn[N];
 
int main() {
	fastio;
	#ifdef ALEXPC
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	FORT(i,1,n){
		cin>>a[i];
		pr[i]=pr[i-1]+a[i];
	}
	ll tv=0;
	FORT(i,1,n){
		if (dn[i])tv=max(tv,dn[i]);
		dp1[i]=dp1[tv]+1;
		dp2[i]=pr[i]-pr[tv];
		dn[lower_bound(pr,pr+n+1,pr[i]+dp2[i])-pr]=i;
	}
	cout<<dp1[n]<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 3 ms 632 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 3 ms 504 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 2 ms 504 KB Output is correct
43 Correct 2 ms 504 KB Output is correct
44 Correct 2 ms 504 KB Output is correct
45 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 3 ms 632 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 3 ms 504 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 2 ms 504 KB Output is correct
43 Correct 2 ms 504 KB Output is correct
44 Correct 2 ms 504 KB Output is correct
45 Correct 2 ms 508 KB Output is correct
46 Correct 16 ms 3960 KB Output is correct
47 Correct 19 ms 4600 KB Output is correct
48 Correct 24 ms 5112 KB Output is correct
49 Correct 25 ms 5112 KB Output is correct
50 Correct 25 ms 5304 KB Output is correct
51 Correct 26 ms 5244 KB Output is correct
52 Correct 14 ms 2808 KB Output is correct
53 Correct 9 ms 1912 KB Output is correct
54 Correct 18 ms 4472 KB Output is correct
55 Correct 26 ms 5240 KB Output is correct
56 Correct 21 ms 4736 KB Output is correct
57 Correct 18 ms 4472 KB Output is correct
58 Correct 19 ms 4600 KB Output is correct
59 Correct 22 ms 4856 KB Output is correct
60 Correct 22 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 3 ms 632 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 3 ms 504 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 2 ms 504 KB Output is correct
43 Correct 2 ms 504 KB Output is correct
44 Correct 2 ms 504 KB Output is correct
45 Correct 2 ms 508 KB Output is correct
46 Correct 16 ms 3960 KB Output is correct
47 Correct 19 ms 4600 KB Output is correct
48 Correct 24 ms 5112 KB Output is correct
49 Correct 25 ms 5112 KB Output is correct
50 Correct 25 ms 5304 KB Output is correct
51 Correct 26 ms 5244 KB Output is correct
52 Correct 14 ms 2808 KB Output is correct
53 Correct 9 ms 1912 KB Output is correct
54 Correct 18 ms 4472 KB Output is correct
55 Correct 26 ms 5240 KB Output is correct
56 Correct 21 ms 4736 KB Output is correct
57 Correct 18 ms 4472 KB Output is correct
58 Correct 19 ms 4600 KB Output is correct
59 Correct 22 ms 4856 KB Output is correct
60 Correct 22 ms 4856 KB Output is correct
61 Correct 73 ms 18040 KB Output is correct
62 Correct 75 ms 19960 KB Output is correct
63 Correct 92 ms 21112 KB Output is correct
64 Correct 123 ms 24540 KB Output is correct
65 Correct 122 ms 24824 KB Output is correct
66 Correct 123 ms 24696 KB Output is correct
67 Correct 99 ms 19916 KB Output is correct
68 Correct 50 ms 10104 KB Output is correct
69 Correct 86 ms 20984 KB Output is correct
70 Correct 124 ms 24864 KB Output is correct
71 Correct 95 ms 21904 KB Output is correct
72 Correct 90 ms 20748 KB Output is correct
73 Correct 101 ms 22264 KB Output is correct
74 Correct 108 ms 23260 KB Output is correct
75 Correct 111 ms 23288 KB Output is correct