Submission #990594

#TimeUsernameProblemLanguageResultExecution timeMemory
990594tch1cherinSimple game (IZhO17_game)C++17
22 / 100
1036 ms1316 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> h(N);
  for (int &value : h) {
    cin >> value;
  }
  while (M--) {
    int type;
    cin >> type;
    if (type == 1) {
      int pos, val;
      cin >> pos >> val;
      h[--pos] = val;
    } else {
      int H;
      cin >> H;
      int answer = 0;
      for (int i = 0; i < N - 1; i++) {
        if (h[i] < h[i + 1]) {
          answer += h[i] <= H && H <= h[i + 1];
        } else {
          answer += h[i + 1] <= H && H <= h[i];
        }
      }
      cout << answer << "\n";
    }
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...