Submission #512328

# Submission time Handle Problem Language Result Execution time Memory
512328 2022-01-16T09:30:27 Z Kaguya Po (COCI21_po) C++17
10 / 70
1000 ms 17220 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;
      if (a[i] == x) {
        ans += 1;
        while (i < n && a[i] >= x) {
          if (a[i] == x)
            vis[i] = true;
          i++;
        }
      }  
    }
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 6 ms 956 KB Output isn't correct
5 Incorrect 9 ms 1208 KB Output isn't correct
6 Execution timed out 1075 ms 9484 KB Time limit exceeded
7 Incorrect 58 ms 17220 KB Output isn't correct