답안 #231287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231287 2020-05-13T10:00:57 Z origami100 Baloni (COCI15_baloni) C++11
100 / 100
516 ms 544 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	multiset <ll> num;
	for(ll i = 0; i < n; i++){
		ll a;
		cin >> a;
		if(num.empty()){
			num.insert(a);
		}else{
			multiset <ll>::iterator it;
			it = num.lower_bound(a + 1);
			if(it == num.end()){
				num.insert(a);
			}else if(*it == a + 1){
				num.erase(it);
				num.insert(a);
			}else{
				num.insert(a);
			}
		}
	}
	cout << num.size();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 458 ms 420 KB Output is correct
6 Correct 516 ms 492 KB Output is correct
7 Correct 413 ms 504 KB Output is correct
8 Correct 418 ms 544 KB Output is correct
9 Correct 455 ms 504 KB Output is correct
10 Correct 452 ms 508 KB Output is correct