Submission #91102

# Submission time Handle Problem Language Result Execution time Memory
91102 2018-12-26T09:26:57 Z emil_physmath Money (IZhO17_money) C++14
45 / 100
1500 ms 5900 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;

int a[1000005], dp[1000005];

int main()
{
	int n;
	cin>>n;
	for (int k=0; k<n; k++)
		scanf("%d", a+k);
	set<int>curSorted;
	for (int i=0; i<n; i++)
	{
		dp[i]=i+1;
		for (int j=i; j>=0; j--)
		{
			if (j<i && a[j]>a[j+1]) break;
			curSorted.clear();
			curSorted.insert(0);
			curSorted.insert(10000000);
			for (int k=0; k<j; k++)
				curSorted.insert(a[k]);
			if (a[i]<=*curSorted.upper_bound(a[j]))
				dp[i]=min(dp[i], dp[j-1]+1);
		}
	}
	cout<<dp[n-1]<<'\n';
	//int i=0, ans=0;
	//set<int> curSorted;
	//curSorted.insert(0);
	//curSorted.insert(10000000);
	//while (i<n)
	//{
	//	ans++;
	//	int j=i;
	//	while (j+1<n && a[j+1]>a[j])
	//		j++;
	//	auto rBound=curSorted.upper_bound(a[i]);
	//	j=upper_bound(a+i, a+j+1, *rBound)-a;
	//	for (int k=i; k<j; k++)
	//		curSorted.insert(a[k]);
	//	i=j;
	//}
	//cout<<ans<<'\n';

	char I;
	cin >> I;
	return 0;
}
/*
9
2 5 4 3 5 6 4 6 7
5
1 2 4 3 5
*/

Compilation message

money.cpp: In function 'int main()':
money.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+k);
   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 552 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 552 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 2 ms 700 KB Output is correct
19 Correct 2 ms 700 KB Output is correct
20 Correct 2 ms 700 KB Output is correct
21 Correct 2 ms 700 KB Output is correct
22 Correct 2 ms 700 KB Output is correct
23 Correct 2 ms 700 KB Output is correct
24 Correct 2 ms 700 KB Output is correct
25 Correct 2 ms 700 KB Output is correct
26 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 552 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 2 ms 700 KB Output is correct
19 Correct 2 ms 700 KB Output is correct
20 Correct 2 ms 700 KB Output is correct
21 Correct 2 ms 700 KB Output is correct
22 Correct 2 ms 700 KB Output is correct
23 Correct 2 ms 700 KB Output is correct
24 Correct 2 ms 700 KB Output is correct
25 Correct 2 ms 700 KB Output is correct
26 Correct 2 ms 700 KB Output is correct
27 Correct 4 ms 700 KB Output is correct
28 Correct 2 ms 700 KB Output is correct
29 Correct 2 ms 700 KB Output is correct
30 Correct 2 ms 700 KB Output is correct
31 Correct 2 ms 700 KB Output is correct
32 Correct 3 ms 708 KB Output is correct
33 Correct 3 ms 712 KB Output is correct
34 Correct 3 ms 732 KB Output is correct
35 Correct 3 ms 736 KB Output is correct
36 Correct 3 ms 740 KB Output is correct
37 Correct 4 ms 744 KB Output is correct
38 Correct 4 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 552 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 2 ms 700 KB Output is correct
19 Correct 2 ms 700 KB Output is correct
20 Correct 2 ms 700 KB Output is correct
21 Correct 2 ms 700 KB Output is correct
22 Correct 2 ms 700 KB Output is correct
23 Correct 2 ms 700 KB Output is correct
24 Correct 2 ms 700 KB Output is correct
25 Correct 2 ms 700 KB Output is correct
26 Correct 2 ms 700 KB Output is correct
27 Correct 4 ms 700 KB Output is correct
28 Correct 2 ms 700 KB Output is correct
29 Correct 2 ms 700 KB Output is correct
30 Correct 2 ms 700 KB Output is correct
31 Correct 2 ms 700 KB Output is correct
32 Correct 3 ms 708 KB Output is correct
33 Correct 3 ms 712 KB Output is correct
34 Correct 3 ms 732 KB Output is correct
35 Correct 3 ms 736 KB Output is correct
36 Correct 3 ms 740 KB Output is correct
37 Correct 4 ms 744 KB Output is correct
38 Correct 4 ms 748 KB Output is correct
39 Execution timed out 1543 ms 5900 KB Time limit exceeded
40 Halted 0 ms 0 KB -