답안 #103612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103612 2019-04-01T07:40:07 Z leonarda Baloni (COCI15_baloni) C++14
0 / 100
2000 ms 45716 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;

int n, ans;
set<pi> s;
vector<pi> h;

int main ()
{
	ios::sync_with_stdio(0);
	
	cin >> n;
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		s.insert(make_pair(x, i));
//		h.pb(mp.(x, i));
	}
	
	while(!s.empty()) {
		int x, y;
		tie(x, y) = *(s.rbegin());
		
//		cout << "x " << x << " y " << y << endl;
		
		s.erase(make_pair(x, y));
		--x; ++y;
		
		vector<pi> v;

		for(set<pi>::reverse_iterator it = s.rbegin(); it != s.rend(); ++it) {
			if((*it).first == x and (*it).second >= y) {
				--x; ++y;
				v.pb(*it);
			}
		}
		
//		cout << v.size() << endl;
//		for(int i = 0; i < v.size(); ++i)
//			cout << v[i].first << " " << v[i].second << endl;
		
		for(int i = 0; i < v.size(); ++i) 
			s.erase(v[i]);
			
		++ans;
	}
	
	cout << ans;

return 0;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < v.size(); ++i) 
                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Incorrect 12 ms 512 KB Output isn't correct
3 Incorrect 50 ms 536 KB Output isn't correct
4 Incorrect 58 ms 640 KB Output isn't correct
5 Execution timed out 2036 ms 41184 KB Time limit exceeded
6 Execution timed out 2021 ms 45716 KB Time limit exceeded
7 Execution timed out 2075 ms 37868 KB Time limit exceeded
8 Execution timed out 2044 ms 37360 KB Time limit exceeded
9 Execution timed out 2009 ms 39680 KB Time limit exceeded
10 Execution timed out 2041 ms 41132 KB Time limit exceeded