답안 #494953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494953 2021-12-17T17:51:27 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;
	int mx=a[das];
	for(int k=das;k<=n;k++){
		it=s.upper_bound(a[l]);
		if(a[k]<mx){
			l=k;
			s.insert(a[k]);
			ans++;
			mx=a[k];
			continue;
		}
		if(it==s.end()){
			s.insert(a[k]);
			mx=max(mx,a[k]);
			continue;
		}
		int ind=*it;
		if(ind<a[k]){
			l=k;
			s.insert(a[k]);
			ans++;
			mx=a[k];
			continue;
		}
		s.insert(a[k]);
		mx=max(mx,a[k]);
	}
	cout<<ans+1;
    return 0;
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -