답안 #51858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51858 2018-06-22T06:27:48 Z Adhyyan1252 Baloni (COCI15_baloni) C++11
10 / 100
1597 ms 104404 KB
#include<bits/stdc++.h>

using namespace std;
typedef pair<int, int> ii;
//1143
#define HMAX 1000004
set<int> a[HMAX];

int main(){
	int n; cin>>n;
	int h[n];
	for(int i = 0; i < n; i++){
		int t; cin>>t;
		a[t].insert(i);
	}
	int ans = 0;
	for(int cur = HMAX-1; cur >= 1; cur--){
		if(a[cur].size() == 0) continue;
		ans++;
		int indx = *a[cur].begin();
		a[cur].erase(a[cur].begin());
		int temp = cur-1;
		set<int>::iterator it;
		while((it = a[temp].lower_bound(indx)) != a[temp].end()){
			indx = *it;
			a[temp].erase(it);
			temp--;
		}
	}
	cout<<ans<<endl;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:11:6: warning: unused variable 'h' [-Wunused-variable]
  int h[n];
      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 47480 KB Output isn't correct
2 Incorrect 53 ms 47480 KB Output isn't correct
3 Incorrect 53 ms 47568 KB Output isn't correct
4 Incorrect 52 ms 47772 KB Output isn't correct
5 Correct 1597 ms 88376 KB Output is correct
6 Incorrect 1431 ms 96624 KB Output isn't correct
7 Incorrect 1048 ms 96624 KB Output isn't correct
8 Incorrect 1245 ms 96624 KB Output isn't correct
9 Incorrect 1548 ms 99772 KB Output isn't correct
10 Incorrect 1338 ms 104404 KB Output isn't correct