Submission #92645

# Submission time Handle Problem Language Result Execution time Memory
92645 2019-01-04T09:20:19 Z janchomath Money (IZhO17_money) C++14
0 / 100
2 ms 380 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[2000005],ans,x;
set<ll>st;
set<ll>::iterator it;
int main(){
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	
	for(int i=1; i<=n; i++){
		//cout << i << endl;
		if(st.size()){
			if((*st.begin()) >= a[i]){
				x = (*st.begin());
			}
			else {
				it = st.lower_bound(a[i]);
				if(it == st.end())x = 999999999999999;
				else x = (*it);
			}
		}
		else {
			x = 9999999999999;
		}
		//cout << x << "<--\n";
		ll l = i + 1;
		while(a[l] >= a[l-1] && a[l] <= x){
			l++;
		}
		for(int j=i; j<l; j++){
			st.insert(a[j]);
		}
		i = l - 1;
		ans++;
	}
	
	cout << ans;
	
	
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -