제출 #758173

#제출 시각아이디문제언어결과실행 시간메모리
758173vjudge1Simple game (IZhO17_game)C++17
49 / 100
45 ms6784 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 1000007 #define INF 1000000000000000000 //#define ll long long ///#define cin fin ///#define cout fout #define fi first #define se second using namespace std; double const EPS = 1e-14; ///ofstream fout("herding.out"); ///ifstream fin("herding.in"); const int Max = 1e6 + 5; const int M = 1e6; int cnt[Max]; int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n, m; cin >> n >> m; int arr[n]; for(int i = 0; i < n; i++) cin >> arr[i]; for(int i = 1; i < n; i++) { if(arr[i-1] < arr[i]) { cnt[arr[i-1]]++; cnt[arr[i]+1]--; } else if(arr[i-1] != arr[i]) { cnt[arr[i-1]]--; cnt[arr[i]+1]++; } } for(int i = 1; i <= M; i++) { cnt[i] += cnt[i-1]; } if(n <= 1000) { while(m--) { int ty; cin >> ty; if(ty == 1) { int pos, val; cin >> pos >> val; arr[pos-1] = val; } else { int h, ans = 0; cin >> h; bool ok; if(arr[0] < h) ok = false; else ok = true; for(int i = 1; i < n; i++) { if(arr[i] > h && ok == false) { ans++; ok = true; } else if(arr[i] < h && ok == true) { ans++; ok = false; } } cout << ans << endl; } }} else { while(m--) { int ty; cin >> ty; if(ty == 1) { int pos, val; cin >> pos >> val; arr[pos-1] = val; } else { int h; cin >> h; cout << cnt[h] << endl; } } } return 0; } /*3 3 1 5 1 2 3 1 1 5 2 3*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...