Submission #311763

# Submission time Handle Problem Language Result Execution time Memory
311763 2020-10-11T13:55:44 Z kaplanbar Baloni (COCI15_baloni) C++14
100 / 100
1449 ms 42104 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e6+5;
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    map<int,set<int>> v;
    for(int i = 0; i < n; i++) {
      int x;
      cin >> x;
      v[-x].insert(i);
    }
    int c = 0;
    for(auto &x : v) {
      while(!x.second.empty()) {
        c++;
        int now = -x.first;
        int pos = -1;
        while(v[-now].upper_bound(pos) != v[-now].end()) {
          int x = *v[-now].upper_bound(pos);
          pos = x;
          v[-now].erase(pos);
          now--;
        }
      }
    }
    cout << c << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 1270 ms 37796 KB Output is correct
6 Correct 1449 ms 42104 KB Output is correct
7 Correct 1147 ms 34840 KB Output is correct
8 Correct 1128 ms 34424 KB Output is correct
9 Correct 1208 ms 36344 KB Output is correct
10 Correct 1253 ms 37892 KB Output is correct