Submission #37562

# Submission time Handle Problem Language Result Execution time Memory
37562 2017-12-26T06:26:33 Z Abelyan Money (IZhO17_money) C++14
0 / 100
0 ms 10964 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int N=1000006;
pair <int,int> a[N];
bool r[N];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	for (int i = 0; i < n; i++){
		int k;
		cin>>k;
		a[i].first=k;
		a[i].second=-i;
	}
	sort(a,a+n);
	int ans=1;
	r[-a[0].second+1]=true;
	for (int i = 1; i < n; i++){
		if (r[-a[i].second]){
			r[-a[i-1].second+1]=false;
			r[-a[i].second+1]=true;
		}
		else{
			if (-a[i].second < -a[i - 1].second){
				r[-a[i - 1].second + 1] = false;
				r[-a[i].second + 1] = true;
			}
			else{
				r[-a[i].second + 1] = true;
			}
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10964 KB Output is correct
2 Correct 0 ms 10964 KB Output is correct
3 Correct 0 ms 10964 KB Output is correct
4 Incorrect 0 ms 10964 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10964 KB Output is correct
2 Correct 0 ms 10964 KB Output is correct
3 Correct 0 ms 10964 KB Output is correct
4 Incorrect 0 ms 10964 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10964 KB Output is correct
2 Correct 0 ms 10964 KB Output is correct
3 Correct 0 ms 10964 KB Output is correct
4 Incorrect 0 ms 10964 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10964 KB Output is correct
2 Correct 0 ms 10964 KB Output is correct
3 Correct 0 ms 10964 KB Output is correct
4 Incorrect 0 ms 10964 KB Output isn't correct
5 Halted 0 ms 0 KB -