답안 #381743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381743 2021-03-25T20:02:47 Z 4fecta Meteors (POI11_met) C++14
74 / 100
1262 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define int ll
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0); cin.sync_with_stdio(0)

struct query {
    int l, r, x;
};

const int MN = 400005;

int n, m, a[MN], tgt[MN], l[MN], r[MN], q, bit[MN], fck1, fck2, fck3;
vector<int> pos[MN], chk[MN];
query qs[MN];

void upd(int x, int val) {
    for (int i = x + 1; i < MN; i += i & -i) bit[i] += val;
}

int qry(int x) {
    int ret = 0;
    for (int i = x + 1; i > 0; i -= i & -i) ret += bit[i];
    return ret;
}

int32_t main() {
    boost();

    cin >> n >> m;
    for (int i = 1; i <= m; i++) cin >> a[i], pos[a[i]].push_back(i);
    for (int i = 1; i <= n; i++) cin >> tgt[i];
    cin >> q;
    for (int i = 1; i <= q; i++) cin >> fck1 >> fck2 >> fck3, qs[i] = {fck1, fck2, fck3};
    for (int i = 1; i < MN; i++) l[i] = 1, r[i] = q + 1;
    for (;;) {
        bool brk = true;
        for (long long & i : bit) i = 0;
        for (int i = 1; i <= n; i++) {
            if (l[i] == r[i]) continue;
            int mid = (l[i] + r[i]) / 2;
            chk[mid].push_back(i);
        }
        for (int i = 1; i <= q; i++) {
            if (qs[i].l <= qs[i].r) upd(qs[i].l, qs[i].x), upd(qs[i].r + 1, -qs[i].x);
            else upd(1, qs[i].x), upd(qs[i].r + 1, -qs[i].x), upd(qs[i].l, qs[i].x);
            while (!chk[i].empty()) {
                int id = chk[i].back();
                chk[i].pop_back();
                int sum = 0;
                for (int p : pos[id]) {
                    sum += qry(p);
                    if (sum >= tgt[id]) break;
                }
                if (sum >= tgt[id]) r[id] = i;
                else l[id] = i + 1;
                brk = false;
            }
        }
        if (brk) break;
    }
    for (int i = 1; i <= n; i++) {
        assert(l[i] == r[i]);
        if (l[i] <= q) cout << r[i] << "\n";
        else cout << "NIE\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 28652 KB Output is correct
2 Correct 23 ms 28652 KB Output is correct
3 Correct 23 ms 28652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 28652 KB Output is correct
2 Correct 27 ms 28652 KB Output is correct
3 Correct 24 ms 28652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 31468 KB Output is correct
2 Correct 178 ms 34332 KB Output is correct
3 Correct 142 ms 33644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 32876 KB Output is correct
2 Correct 157 ms 33004 KB Output is correct
3 Correct 178 ms 34868 KB Output is correct
4 Correct 54 ms 31852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 31980 KB Output is correct
2 Correct 176 ms 34948 KB Output is correct
3 Correct 168 ms 30060 KB Output is correct
4 Correct 146 ms 34160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 145 ms 30696 KB Output is correct
2 Correct 164 ms 32744 KB Output is correct
3 Correct 115 ms 31212 KB Output is correct
4 Correct 179 ms 36076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1262 ms 60348 KB Output is correct
2 Correct 981 ms 40436 KB Output is correct
3 Correct 870 ms 34540 KB Output is correct
4 Runtime error 929 ms 65540 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Correct 1210 ms 58592 KB Output is correct
2 Correct 744 ms 40560 KB Output is correct
3 Correct 695 ms 33516 KB Output is correct
4 Runtime error 813 ms 65540 KB Execution killed with signal 9