Submission #81161

#TimeUsernameProblemLanguageResultExecution timeMemory
81161FutymyCloneBaloni (COCI15_baloni)C++14
0 / 100
183 ms32940 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, a[N], ptr[N], ans = 0; bool used[N]; vector <int> pos[N]; int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].push_back(i); for (int i = 1; i <= n; i++) { if (used[i]) continue; ans++; int pt = a[i]; while (pt >= 1) { if (ptr[pt] >= pos[pt].size()) break; used[pos[pt][ptr[pt]++]] = true; pt--; } } printf("%d", ans); return 0; }

Compilation message (stderr)

baloni.cpp: In function 'int main()':
baloni.cpp:19:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ptr[pt] >= pos[pt].size()) break;
                 ~~~~~~~~^~~~~~~~~~~~~~~~~
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]].push_back(i);
                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...