# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
87664 | jvalsortav | Baloni (COCI15_baloni) | C++14 | 2079 ms | 23264 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |