Submission #84359

#TimeUsernameProblemLanguageResultExecution timeMemory
84359zoooma13Baloni (COCI15_baloni)C++14
100 / 100
1571 ms89220 KiB
#include <bits/stdc++.h> using namespace std; #define MAX_N 1000006 int N ,A; set<int> ss[MAX_N]; int cnt[MAX_N]; vector <int> nxt; int main() { scanf("%d",&N); for(int i=0; i<N; i++) { scanf("%d",&A); ss[A].insert(i); if(!cnt[A]++) nxt.push_back(A); } sort(nxt.begin() ,nxt.end()); int Ans = 0; for(int pt = nxt.size()-1; ~pt;) { int i = nxt[pt] ,j = -1; while(true) { auto it = ss[i].upper_bound(j); if(it == ss[i].end()) break; j = *it; ss[i].erase(it); --cnt[i--]; } while(~pt && !cnt[nxt[pt]]) pt--; Ans++; } cout << Ans << endl; }

Compilation message (stderr)

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