Submission #512331

# Submission time Handle Problem Language Result Execution time Memory
512331 2022-01-16T09:34:14 Z Kaguya Po (COCI21_po) C++17
10 / 70
1000 ms 16324 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& t : a)
    cin >> t;
  int ans = 0;
  vector<bool> vis(n, false);
  set<int> se;
  for (int i = 0; i < n; i++)
    se.insert(a[i]);
  map<int, vector<int>> pos;
  for (int i = 0; i < n; i++)
    pos[a[i]].push_back(i);
  while (!se.empty()) {
    int x = *(se.begin());
    se.erase(se.begin());
    for (auto t : pos[x]) {
      if (vis[t])
        continue;
      vis[t] = true;
      int i = t;
      ans += 1;
      while (i < n && a[i] >= x) {
        if (a[i] == x)
          vis[i] = true;
        i++;
      }
      if (a[i] == x)
        vis[i] = true;
    }
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Incorrect 6 ms 844 KB Output isn't correct
5 Incorrect 10 ms 1100 KB Output isn't correct
6 Execution timed out 1081 ms 8500 KB Time limit exceeded
7 Incorrect 60 ms 16324 KB Output isn't correct