Submission #51859

# Submission time Handle Problem Language Result Execution time Memory
51859 2018-06-22T06:35:27 Z Adhyyan1252 Baloni (COCI15_baloni) C++11
100 / 100
1873 ms 89176 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--){
		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;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:11:6: warning: unused variable 'h' [-Wunused-variable]
  int h[n];
      ^
# Verdict Execution time Memory Grader output
1 Correct 52 ms 47352 KB Output is correct
2 Correct 51 ms 47476 KB Output is correct
3 Correct 49 ms 47520 KB Output is correct
4 Correct 51 ms 47620 KB Output is correct
5 Correct 1616 ms 84792 KB Output is correct
6 Correct 1873 ms 89176 KB Output is correct
7 Correct 1313 ms 89176 KB Output is correct
8 Correct 1202 ms 89176 KB Output is correct
9 Correct 1346 ms 89176 KB Output is correct
10 Correct 1428 ms 89176 KB Output is correct