답안 #89874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89874 2018-12-18T17:44:25 Z popovicirobert 돌 무게 재기 (IZhO11_stones) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int MAXN = (int) 1e5;

struct Aint {
    int mn, mx;
    int lazy;
}aint[4 * MAXN + 1];

inline void refresh(int nod) {
    aint[nod].mn = min(aint[2 * nod].mn, aint[2 * nod + 1].mn);
    aint[nod].mx = max(aint[2 * nod].mx, aint[2 * nod + 1].mx);
}

inline void solve_lazy(int nod) {
    if(2 * nod + 1 <= 4 * MAXN) {
        aint[2 * nod].mn += aint[nod].lazy;
        aint[2 * nod + 1].mx += aint[nod].lazy;
        aint[2 * nod + 1].mn += aint[nod].lazy;
        aint[2 * nod + 1].mx += aint[nod].lazy;
        refresh(nod);
    }
    aint[nod].lazy = 0;
}

void update(int nod, int left, int right, int l, int r, int val) {
    solve_lazy(nod);
    if(l <= left && right <= r) {
        aint[nod].lazy += val;
        solve_lazy(nod);
    }
    else {
        int mid = (left + right) / 2;
        if(l <= mid)
            update(2 * nod, left, mid, l, r, val);
        else
            update(2 * nod + 1, mid + 1, right, l, r, val);
        refresh(nod);
    }
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for(i = 1; i <= n; i++) {
        int r, s;
        cin >> r >> s;
        if(s == 1) {
            update(1, 1, n, 1, r, 1);
        }
        else {
            update(1, 1, n, 1, r, -1);
        }
        if(aint[1].mn >= 0) {
            cout << '>';
        }
        else if(aint[1].mx <= 0) {
            cout << '<';
        }
        else {
            cout << '?';
        }
        cout << "\n";
    }
    //cin.close();
    //cout.close();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -