답안 #91098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91098 2018-12-26T09:06:30 Z emil_physmath Money (IZhO17_money) C++14
0 / 100
2 ms 652 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;

int a[1000005];

int main()
{
	int n;
	cin>>n;
	for (int k=0; k<n; k++)
		scanf("%d", a+k);
	int i=0, ans=0;
	set<int> curSorted;
	curSorted.insert(0);
	while (i<n)
	{
		ans++;
		int j=i;
		while (j+1<n && a[j+1]>a[j])
			j++;
		auto lBound=curSorted.upper_bound(a[i]);
		lBound--;
		auto rBound=(lBound==curSorted.end()?curSorted.begin():++lBound);
		if (rBound!=curSorted.end())
			j=upper_bound(a+i, a+j+1, *rBound)-a-1;
		for (int k=i; k<=j; k++)
			curSorted.insert(a[k]);
		i=j+1;
	}
	cout<<ans<<'\n';

	char I;
	cin >> I;
	return 0;
}

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);
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Incorrect 2 ms 652 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Incorrect 2 ms 652 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Incorrect 2 ms 652 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Incorrect 2 ms 652 KB Output isn't correct
8 Halted 0 ms 0 KB -