Submission #319313

# Submission time Handle Problem Language Result Execution time Memory
319313 2020-11-04T16:36:00 Z kshitij_sodani Money (IZhO17_money) C++14
0 / 100
1 ms 492 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
//#define endl '\n'
int n;
int it[1000001];
int tree[1000001];
void u(int i,int j){
	while(i<1000001){
		tree[i]+=j;
		i+=(i&-i);
	}
}
int ss(int i){
	int su=0;
	while(i>0){
		su+=tree[i];
		i-=(i&-i);
	}
	return su;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;

	for(int i=0;i<n;i++){
		cin>>it[i];
	//	u(it[i],1);
	}
	int ans=1;
	u(it[0],1);
	for(int i=1;i<n;i++){
		if(it[i]>=it[i-1]){
			if(ss(it[i]-1)-ss(it[i-1])<=0){

			}
			else{
				ans+=1;
			}
		}
		else{
			ans+=1;
		}
		u(it[i],1);
	}
	cout<<ans<<endl;
	return 0;
/*	int ind=0;
	int ans=0;
//	u(it[0],-1);
	while(ind<n){
		int mi=it[ind];
		int ma=it[ind];
		ans++;
		//cout<<ind<<":"<<endl;
		int pre=ind;

		ind++;
		//u(it[ind],1);
		//u(it[ind],-1);
		
		while(ind<n){
			if(it[ind]<ma){
				break;
			}
			mi=min(mi,it[ind]);
			ma=max(ma,it[ind]);
		//	cout<<ind<<":"<<endl;
			if(ss(ma-1)-ss(mi)==0){
				//u(it[ind],1);
				ind++;
				continue;
			}
			break;
		}
		for(int i=pre;i<ind;i++){
			u(it[i],1);
		}
	}
	cout<<ans<<endl;*/

	return 0;
}
/*
6
3 6 4 5 1 2*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -