Submission #853293

# Submission time Handle Problem Language Result Execution time Memory
853293 2023-09-24T01:45:18 Z NeroZein Money (IZhO17_money) C++17
0 / 100
1 ms 2392 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif

const int N = 1e6 + 6;

int a[N];
int seg[N * 2];
int tt[N];

void upd(int i, int val) {
  tt[i] = val;
}

int get(int l, int r) {
  int ret = 0;
  for (int i = l; i <= r; ++i) {
    ret = max(ret, tt[i]); 
  }
  return ret;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 1;
  vector<int> v = {a[0]};
  upd(a[0], a[0]);
  for (int i = 1; i < n; ++i) {
    if (v.back() > a[i]) {
      ans++; 
      v.clear();
      v.push_back(a[i]); 
      upd(a[i], a[i]);
    } else {
      if (get(v[0], a[i]) > a[i]) {
        ans++;
        v.clear();
        v.push_back(a[i]); 
        upd(a[i], a[i]); 
      } else {
        deb(i); cout << '\n';
        v.push_back(a[i]); 
        upd(v[0], a[i]); 
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -