Submission #81164

#TimeUsernameProblemLanguageResultExecution timeMemory
81164FutymyCloneBaloni (COCI15_baloni)C++14
100 / 100
1441 ms93528 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, a[N], ans = 0; set <int> pos[N]; bool used[N]; int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].insert(i); for (int i = 1; i <= n; i++) { if (used[i]) continue; ans++; int pt = a[i], lst = i; while (pt >= 1) { auto it = pos[pt].lower_bound(lst); if (it == pos[pt].end()) break; lst = *it; pos[pt].erase(it); used[lst] = true; pt--; } } printf("%d", ans); return 0; }

Compilation message (stderr)

baloni.cpp: In function 'int main()':
baloni.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
baloni.cpp:13:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].insert(i);
                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...