Submission #51859

#TimeUsernameProblemLanguageResultExecution timeMemory
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; }

Compilation message (stderr)

baloni.cpp: In function 'int main()':
baloni.cpp:11:6: warning: unused variable 'h' [-Wunused-variable]
  int h[n];
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...