Submission #878960

# Submission time Handle Problem Language Result Execution time Memory
878960 2023-11-25T19:28:19 Z ArashJafariyan Meteors (POI11_met) C++17
74 / 100
958 ms 53320 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define pb push_back
#define int long long

const int N = 3e5 + 4;

int n, m, k, p[N], lq[N], rq[N], aq[N], l[N], mid[N], r[N], sum[N];
vector<int> own[N], mids[N];

bool update() {
    for (int i = 1; i <= k + 1; ++i) {
        mids[i].clear();
    }
    for (int i = 1; i < N; ++i) {
        sum[i] = 0;
    } 

    bool ret = false;
    for (int i = 1; i <= n; ++i) {
        mid[i] = (l[i] + r[i]) / 2;
        mids[mid[i]].pb(i);
        if (r[i] - l[i] > 1) {
            ret = true;
        }
    }
    return ret;
}

void modify(int id, int val) {
    for (; id < N; id += id & -id) {
        sum[id] += val;
    }
}

int get(int id) {
    int ret = 0;
    for (; id; id -= id & -id) {
        ret += sum[id];
    }
    return ret;
}

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

    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int o;
        cin >> o;
        own[o].pb(i);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }
    cin >> k;
    for (int i = 1; i <= k; ++i) {
       cin >> lq[i] >> rq[i] >> aq[i];
    }

    lq[k + 1] = 1;
    rq[k + 1] = m;
    aq[k + 1] = (int) 1e9;
    for (int i = 1; i <= n; ++i) {
        l[i] = 0;
        r[i] = k + 1;
    }
    while (update() == true) {
        for (int i = 1; i <= k + 1; ++i) {
            if (lq[i] > rq[i]) {
                modify(1, aq[i]);
                modify(rq[i] + 1, -aq[i]);
                modify(lq[i], aq[i]);
            }
            else {
                modify(lq[i], aq[i]);
                modify(rq[i] + 1, -aq[i]);
            }
           
            for (int idx : mids[i]) {
                int s = 0;
                for (int o : own[idx]) {
                    s += get(o);
                }
                if (s >= p[idx]) {
                    r[idx] = i;
                }
                else {
                    l[idx] = i;
                }
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (r[i] == k + 1) {
            cout << "NIE";
        }
        else {
            cout << r[i];
        }
        cout << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 29276 KB Output is correct
2 Correct 7 ms 29432 KB Output is correct
3 Correct 7 ms 29276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 29368 KB Output is correct
2 Correct 7 ms 29276 KB Output is correct
3 Correct 7 ms 29276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 30548 KB Output is correct
2 Correct 135 ms 35584 KB Output is correct
3 Correct 84 ms 32592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 32032 KB Output is correct
2 Correct 102 ms 31996 KB Output is correct
3 Correct 137 ms 35844 KB Output is correct
4 Correct 26 ms 32092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 31080 KB Output is correct
2 Correct 183 ms 35948 KB Output is correct
3 Correct 96 ms 29272 KB Output is correct
4 Correct 85 ms 33236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 29948 KB Output is correct
2 Correct 123 ms 31904 KB Output is correct
3 Correct 66 ms 30384 KB Output is correct
4 Correct 119 ms 37076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 952 ms 53320 KB Output is correct
2 Incorrect 770 ms 31868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 958 ms 51452 KB Output is correct
2 Incorrect 839 ms 31832 KB Output isn't correct
3 Halted 0 ms 0 KB -