제출 #51859

#제출 시각아이디문제언어결과실행 시간메모리
51859Adhyyan1252Baloni (COCI15_baloni)C++11
100 / 100
1873 ms89176 KiB
#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--){
		while(a[cur].size() != 0){
			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;
}

컴파일 시 표준 에러 (stderr) 메시지

baloni.cpp: In function 'int main()':
baloni.cpp:11:6: warning: unused variable 'h' [-Wunused-variable]
  int h[n];
      ^
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…