답안 #87664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87664 2018-12-01T17:24:17 Z jvalsortav Baloni (COCI15_baloni) C++14
0 / 100
2000 ms 23264 KB
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <vector>
#include <map>
using namespace std;

int n, x, b, l;
vector <int> v;
set <int> s;
map <int, int> m;

int main() {
	
	cin >> n;
	
	for (int i = 0; i < n; i++){
		cin >> x;
		v.push_back(x);
		s.insert(x);
		m[x]++;
	}
	
	while (s.size()){
		b++;
		x = *s.rbegin();
		if (m[x] > 1) m[x]--;
		else s.erase(x); 
		
		for (int i = 0; i < n; i++){
			if (x == 0) break;
			if (v[i] == -1) continue;
			if (v[i] == x){
				if (m[x] > 1) m[x]--;
				else s.erase(x);
				x--;
				v[i] = -1;
			}
		}
	}
	
	cout << b;
	



return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Incorrect 11 ms 376 KB Output isn't correct
3 Incorrect 26 ms 660 KB Output isn't correct
4 Incorrect 36 ms 808 KB Output isn't correct
5 Execution timed out 2040 ms 7824 KB Time limit exceeded
6 Execution timed out 2077 ms 11708 KB Time limit exceeded
7 Execution timed out 2050 ms 14528 KB Time limit exceeded
8 Execution timed out 2079 ms 17248 KB Time limit exceeded
9 Execution timed out 2064 ms 20396 KB Time limit exceeded
10 Execution timed out 2074 ms 23264 KB Time limit exceeded