Submission #85532

# Submission time Handle Problem Language Result Execution time Memory
85532 2018-11-20T18:48:20 Z farukkastamonuda Money (IZhO17_money) C++14
0 / 100
2 ms 508 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 1000005
using namespace std;
int n,A[li],flag,tut=1,cev=1;
set<int> s;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	s.insert(inf);
	s.insert(A[1]);
	for(int i=2;i<=n;i++){
		if(A[i]>=A[i-1]){
			s.insert(A[i]);
			tut=i;
		}
		else break;
	}
	int bas=tut+1;
	if(bas<=n) cev++;
	for(int i=tut+1;i<=n;i++){
		//~ printf("I :: %d CEV :: %d\n",i,cev);
		if(i==bas || A[i]>=A[i-1]){
			int it1=*s.upper_bound(A[i]);
			int it2=*s.upper_bound(A[bas]);
			//~ cout<<"YETETETETETETETETERRRETETE::: :: "<<it1<<"   "<<it2<<endl; 
			if(it1==it2) {s.insert(A[i]);}
			else{
				//~ cout<<"EASAS :: : : "<<i<<endl;
				cev++;
				bas=i;
				i--;
			}
		}
		else{
			bas=i;
			cev++;
			i--;
		}
	}
	printf("%d\n",cev);
	return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
money.cpp:15:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&A[i]);
                        ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Incorrect 2 ms 508 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Incorrect 2 ms 508 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Incorrect 2 ms 508 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Incorrect 2 ms 508 KB Output isn't correct
5 Halted 0 ms 0 KB -