답안 #494955

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494955 2021-12-17T17:58:28 Z luka1234 Money (IZhO17_money) C++14
0 / 100
1 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=a[das];
	for(int k=das;k<=n;k++){
		it=s.upper_bound(a[l]);
		if(a[k]<mx){
			l=k;
			ans++;
			mx=a[k];
			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=a[k];
			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;
}
# 결과 실행 시간 메모리 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 1 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 1 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 1 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 1 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -