Submission #40867

#TimeUsernameProblemLanguageResultExecution timeMemory
40867XmtosXBaloni (COCI15_baloni)C++14
60 / 100
2094 ms131072 KiB
#include <bits/stdc++.h> using namespace std; int n,h,ans; set <int> s[1000006]; int main() { scanf("%d",&n); for (int i=0;i<n;i++) { scanf("%d",&h); s[h].insert(i); } for (int i=0;i<=1e6;i++) s[i].insert(n); for (int i=1e6;i>0;i--) { while (s[i].size()>1) { ans++; int x= (*s[i].begin()); s[i].erase(s[i].begin()); int a=i-1; while (s[a].lower_bound(x)!=(--s[a].end())) { x= (*s[a].lower_bound(x)); s[a].erase(x); a--; } } } cout <<ans; return 0; }

Compilation message (stderr)

baloni.cpp: In function 'int main()':
baloni.cpp:7:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
baloni.cpp:10:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&h);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...