Submission #494958

# Submission time Handle Problem Language Result Execution time Memory
494958 2021-12-17T18:02:30 Z luka1234 Money (IZhO17_money) C++14
0 / 100
0 ms 204 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int main(){
	int n;
	cin>>n;
	multiset<int> s;
	int a[n+1];
	for(int k=1;k<=n;k++){
		cin>>a[k];
	}
	s.insert(a[1]);
	int das=1;
	int ans=1;
	for(int k=2;k<=n;k++){
		if(a[k]>a[k-1]){
			s.insert(a[k]);
		}
		else{
			das=k;
		    break;
		}
	}
	int l=das;
	multiset<int>::iterator it;
	vector<int> v;
	int mx=0;
	for(int k=das;k<=n;k++){
		it=s.upper_bound(a[l]);
		if(a[k]<mx){
			l=k;
			ans++;
			mx=0;
			for(int i:v)
			    s.insert(i);
			v.clear();
			continue;
		}
		if(it==s.end()){
			mx=max(mx,a[k]);
			v.push_back(a[k]);
			continue;
		}
		int ind=*it;
		if(ind<a[k]){
			l=k;
			ans++;
			mx=0;
			for(int i:v)
			    s.insert(i);
			v.clear();
			continue;
		}
		v.push_back(a[k]);
		mx=max(mx,a[k]);
	}
	cout<<ans+1;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -