답안 #758173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758173 2023-06-14T08:41:09 Z vjudge1 Simple game (IZhO17_game) C++17
49 / 100
45 ms 6784 KB
#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*/
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4180 KB Output is correct
2 Correct 6 ms 4208 KB Output is correct
3 Correct 6 ms 4180 KB Output is correct
4 Correct 6 ms 4180 KB Output is correct
5 Correct 6 ms 4180 KB Output is correct
6 Correct 6 ms 4180 KB Output is correct
7 Correct 5 ms 4212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4180 KB Output is correct
2 Correct 6 ms 4208 KB Output is correct
3 Correct 6 ms 4180 KB Output is correct
4 Correct 6 ms 4180 KB Output is correct
5 Correct 6 ms 4180 KB Output is correct
6 Correct 6 ms 4180 KB Output is correct
7 Correct 5 ms 4212 KB Output is correct
8 Correct 31 ms 5112 KB Output is correct
9 Correct 37 ms 6784 KB Output is correct
10 Correct 45 ms 6732 KB Output is correct
11 Correct 27 ms 5456 KB Output is correct
12 Correct 33 ms 6576 KB Output is correct
13 Correct 37 ms 6640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4180 KB Output is correct
2 Correct 6 ms 4208 KB Output is correct
3 Correct 6 ms 4180 KB Output is correct
4 Correct 6 ms 4180 KB Output is correct
5 Correct 6 ms 4180 KB Output is correct
6 Correct 6 ms 4180 KB Output is correct
7 Correct 5 ms 4212 KB Output is correct
8 Correct 31 ms 5112 KB Output is correct
9 Correct 37 ms 6784 KB Output is correct
10 Correct 45 ms 6732 KB Output is correct
11 Correct 27 ms 5456 KB Output is correct
12 Correct 33 ms 6576 KB Output is correct
13 Correct 37 ms 6640 KB Output is correct
14 Incorrect 38 ms 6716 KB Output isn't correct
15 Halted 0 ms 0 KB -