Submission #758217

# Submission time Handle Problem Language Result Execution time Memory
758217 2023-06-14T09:35:43 Z vjudge1 Simple game (IZhO17_game) C++17
22 / 100
27 ms 2048 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e7+9;
const int N=100005;//2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;

int nm[N];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n,m; cin>>n>>m;
    int v[n];
    for (int i=0;i<n;i++) cin>>v[i];

    if (n<=1000) {
      while (m--) {
      int t; cin>>t;
      if (t==1) {
        int i,x; cin>>i>>x; i--;
        v[i]=x;
      }
      else {
        int h; cin>>h;
        int ans=0;
        for (int i=0;i+1<n;i++) {
          if ((v[i]<h && v[i+1]>h) || (v[i]>h && v[i+1]<h)) ans++;
        }
        cout<<ans<<endl;
      }
    }
    return 0;
    }

    for (int i=0;i+1<n;i++) {
      nm[min(v[i],v[i+1])]++;
      nm[max(v[i],v[i+1])]--;
    }
    for (int i=1;i<100005;i++) {
      nm[i]+=nm[i-1];
    }
    while (m--) {
      int t,h; cin>>t>>h;
      cout<<nm[h]<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 27 ms 2048 KB Output is correct
9 Runtime error 9 ms 2004 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 27 ms 2048 KB Output is correct
9 Runtime error 9 ms 2004 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -