Submission #87664

#TimeUsernameProblemLanguageResultExecution timeMemory
87664jvalsortavBaloni (COCI15_baloni)C++14
0 / 100
2079 ms23264 KiB
#include <cstdio> #include <cstdlib> #include <cmath> #include <iostream> #include <cctype> #include <ctime> #include <set> #include <vector> #include <map> using namespace std; int n, x, b, l; vector <int> v; set <int> s; map <int, int> m; int main() { cin >> n; for (int i = 0; i < n; i++){ cin >> x; v.push_back(x); s.insert(x); m[x]++; } while (s.size()){ b++; x = *s.rbegin(); if (m[x] > 1) m[x]--; else s.erase(x); for (int i = 0; i < n; i++){ if (x == 0) break; if (v[i] == -1) continue; if (v[i] == x){ if (m[x] > 1) m[x]--; else s.erase(x); x--; v[i] = -1; } } } cout << b; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...