답안 #341307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341307 2020-12-29T12:40:06 Z nandonathaniel Money (IZhO17_money) C++14
45 / 100
384 ms 262148 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+5;
int a[MAXN],dp[MAXN],mini,maxi;

set<int> S;
set<int> simpan[MAXN];

bool valid(int id){
	if(mini==maxi)return true;
	auto it=simpan[id].upper_bound(mini);
	auto it2=simpan[id].lower_bound(maxi);
	return it==it2;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)cin >> a[i];
	S.insert(0);
	S.insert(1e6+5);
	simpan[0]=S;
	for(int i=1;i<=n;i++){
		dp[i]=1e9;
		mini=a[i];maxi=a[i];
		for(int j=i-1;j>=0;j--){
			if(valid(j))dp[i]=min(dp[i],dp[j]+1);
			mini=min(mini,a[j]);
			maxi=max(maxi,a[j]);
			if(a[j]>a[j+1])break;
		}
		S.insert(a[i]);
		simpan[i]=S;
	}
	cout << dp[n] << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 47340 KB Output is correct
2 Correct 32 ms 47340 KB Output is correct
3 Correct 31 ms 47340 KB Output is correct
4 Correct 31 ms 47340 KB Output is correct
5 Correct 34 ms 47340 KB Output is correct
6 Correct 32 ms 47340 KB Output is correct
7 Correct 31 ms 47340 KB Output is correct
8 Correct 30 ms 47340 KB Output is correct
9 Correct 31 ms 47340 KB Output is correct
10 Correct 31 ms 47360 KB Output is correct
11 Correct 31 ms 47340 KB Output is correct
12 Correct 31 ms 47340 KB Output is correct
13 Correct 31 ms 47340 KB Output is correct
14 Correct 31 ms 47340 KB Output is correct
15 Correct 31 ms 47340 KB Output is correct
16 Correct 30 ms 47340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 47340 KB Output is correct
2 Correct 32 ms 47340 KB Output is correct
3 Correct 31 ms 47340 KB Output is correct
4 Correct 31 ms 47340 KB Output is correct
5 Correct 34 ms 47340 KB Output is correct
6 Correct 32 ms 47340 KB Output is correct
7 Correct 31 ms 47340 KB Output is correct
8 Correct 30 ms 47340 KB Output is correct
9 Correct 31 ms 47340 KB Output is correct
10 Correct 31 ms 47360 KB Output is correct
11 Correct 31 ms 47340 KB Output is correct
12 Correct 31 ms 47340 KB Output is correct
13 Correct 31 ms 47340 KB Output is correct
14 Correct 31 ms 47340 KB Output is correct
15 Correct 31 ms 47340 KB Output is correct
16 Correct 30 ms 47340 KB Output is correct
17 Correct 32 ms 47476 KB Output is correct
18 Correct 31 ms 47360 KB Output is correct
19 Correct 31 ms 47348 KB Output is correct
20 Correct 31 ms 47340 KB Output is correct
21 Correct 31 ms 47340 KB Output is correct
22 Correct 33 ms 47340 KB Output is correct
23 Correct 31 ms 47340 KB Output is correct
24 Correct 31 ms 47340 KB Output is correct
25 Correct 31 ms 47340 KB Output is correct
26 Correct 32 ms 47340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 47340 KB Output is correct
2 Correct 32 ms 47340 KB Output is correct
3 Correct 31 ms 47340 KB Output is correct
4 Correct 31 ms 47340 KB Output is correct
5 Correct 34 ms 47340 KB Output is correct
6 Correct 32 ms 47340 KB Output is correct
7 Correct 31 ms 47340 KB Output is correct
8 Correct 30 ms 47340 KB Output is correct
9 Correct 31 ms 47340 KB Output is correct
10 Correct 31 ms 47360 KB Output is correct
11 Correct 31 ms 47340 KB Output is correct
12 Correct 31 ms 47340 KB Output is correct
13 Correct 31 ms 47340 KB Output is correct
14 Correct 31 ms 47340 KB Output is correct
15 Correct 31 ms 47340 KB Output is correct
16 Correct 30 ms 47340 KB Output is correct
17 Correct 32 ms 47476 KB Output is correct
18 Correct 31 ms 47360 KB Output is correct
19 Correct 31 ms 47348 KB Output is correct
20 Correct 31 ms 47340 KB Output is correct
21 Correct 31 ms 47340 KB Output is correct
22 Correct 33 ms 47340 KB Output is correct
23 Correct 31 ms 47340 KB Output is correct
24 Correct 31 ms 47340 KB Output is correct
25 Correct 31 ms 47340 KB Output is correct
26 Correct 32 ms 47340 KB Output is correct
27 Correct 34 ms 48236 KB Output is correct
28 Correct 31 ms 47468 KB Output is correct
29 Correct 32 ms 47468 KB Output is correct
30 Correct 32 ms 47468 KB Output is correct
31 Correct 31 ms 47596 KB Output is correct
32 Correct 32 ms 47468 KB Output is correct
33 Correct 31 ms 47340 KB Output is correct
34 Correct 32 ms 47468 KB Output is correct
35 Correct 31 ms 47340 KB Output is correct
36 Correct 31 ms 47340 KB Output is correct
37 Correct 32 ms 47980 KB Output is correct
38 Correct 32 ms 47980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 47340 KB Output is correct
2 Correct 32 ms 47340 KB Output is correct
3 Correct 31 ms 47340 KB Output is correct
4 Correct 31 ms 47340 KB Output is correct
5 Correct 34 ms 47340 KB Output is correct
6 Correct 32 ms 47340 KB Output is correct
7 Correct 31 ms 47340 KB Output is correct
8 Correct 30 ms 47340 KB Output is correct
9 Correct 31 ms 47340 KB Output is correct
10 Correct 31 ms 47360 KB Output is correct
11 Correct 31 ms 47340 KB Output is correct
12 Correct 31 ms 47340 KB Output is correct
13 Correct 31 ms 47340 KB Output is correct
14 Correct 31 ms 47340 KB Output is correct
15 Correct 31 ms 47340 KB Output is correct
16 Correct 30 ms 47340 KB Output is correct
17 Correct 32 ms 47476 KB Output is correct
18 Correct 31 ms 47360 KB Output is correct
19 Correct 31 ms 47348 KB Output is correct
20 Correct 31 ms 47340 KB Output is correct
21 Correct 31 ms 47340 KB Output is correct
22 Correct 33 ms 47340 KB Output is correct
23 Correct 31 ms 47340 KB Output is correct
24 Correct 31 ms 47340 KB Output is correct
25 Correct 31 ms 47340 KB Output is correct
26 Correct 32 ms 47340 KB Output is correct
27 Correct 34 ms 48236 KB Output is correct
28 Correct 31 ms 47468 KB Output is correct
29 Correct 32 ms 47468 KB Output is correct
30 Correct 32 ms 47468 KB Output is correct
31 Correct 31 ms 47596 KB Output is correct
32 Correct 32 ms 47468 KB Output is correct
33 Correct 31 ms 47340 KB Output is correct
34 Correct 32 ms 47468 KB Output is correct
35 Correct 31 ms 47340 KB Output is correct
36 Correct 31 ms 47340 KB Output is correct
37 Correct 32 ms 47980 KB Output is correct
38 Correct 32 ms 47980 KB Output is correct
39 Correct 351 ms 212332 KB Output is correct
40 Runtime error 384 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Halted 0 ms 0 KB -