답안 #169164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169164 2019-12-18T18:31:11 Z tselmegkh Money (IZhO17_money) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);

	int ans = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int j = 1;
	multiset<int> ms;
	while(a[j] >= a[j - 1] && j < n){
		ms.insert(a[j]);
		j++;
	}
	int cnt = 0, bound = 0;
	while(j < n){
		if(cnt == 0){
			ans++;
			auto it = ms.upper_bound(a[j]);
			if(a[j] <= *it){
				bound = *it;
			}else{
				//cout << j << '\n';
				bound = 1e9;
			}
			ms.insert(a[j]);
			cnt++;
			j++;
		}else{
			if(a[j] < a[j - 1]){
				cnt = 0;
				continue;
			}else{
				if(a[j] <= bound){
					ms.insert(a[j]);
					cnt++;
					j++;
				}else{
					cnt = 0;
				}
			}
		}	
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -