답안 #496260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496260 2021-12-21T04:18:05 Z ergagan Meteors (POI11_met) C++17
24 / 100
6000 ms 5016 KB
//я так много думал, что опять попал
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define f first
#define s second
#define left(v) v + v
#define right(v) v + v + 1
#define ub upper_bound
#define lb lower_bound

using namespace std;
typedef long long ll;

//17 SEVENTEEN
const long double Pi = acos(-1.0);
const ll dx[] = {0,0,1,-1};
const ll dy[] = {1,-1,0,0};
const ll N = (ll) 1e6 + 17;
const ll M = (ll) 5e3 + 69;
const ll inf = (ll) 1e14 + 3;
const ll mod = (ll) 1e9 + 7;
ll sq(ll x) { return x * x; }

ll zxc = 1, a[N], t[4 * N], uv[4 * N];
ll l, r, i, x;
ll p[N], ans[N], cur[N];

void recalc(ll v) {
    t[v] = t[left(v)] + t[right(v)];
}

void push(ll v, ll tl, ll tr) {
    if (!uv[v]) return;
    if (tl < tr) {
        uv[left(v)] += uv[v];
        uv[right(v)] += uv[v];
    }
    t[v] += uv[v] * 1ll * (tr - tl + 1);
    uv[v] = 0;
}

ll get(ll v, ll tl, ll tr, ll l, ll r) {
    push(v, tl, tr);
    if(l <= tl && tr <= r) return t[v];
    if(tr < l || r < tl) return 0;
    ll tm = (tl + tr) / 2;
    return get(left(v), tl, tm, l, r) + get(right(v), tm + 1, tr, l, r);
}

void upd(ll v, ll tl, ll tr, ll ql, ll qr, ll val) {
    push(v, tl, tr);
    if (tr < ql || qr < tl) return;
    if (ql <= tl && tr <= qr) {
        uv[v] += val;
        push(v, tl, tr);
        return;
    }
    ll mid = (tl + tr) / 2;
    upd(left(v), tl, mid, ql, qr, val);
    upd(right(v), mid + 1, tr, ql, qr, val);
    recalc(v);
}

void solve() {
    ll n, m, q;
    cin >> n >> m;
    for(ll i = 1; i <= m; i++) {
        cin >> p[i];
    }
    for(ll i = 1; i <= n; i++) {
        cin >> a[i];
    }
    cin >> q;

    fill(ans + 1, ans + n + 1, -1);
    for(ll time = 0; time < q; time++) {
        for(ll i = 1; i <= n; i++) {
            if(cur[i] >= a[i] && !(~ans[i])) ans[i] = time;
//            cout << cur[i] << " ";
        }
//        cout << "\n";
        cin >> l >> r >> x;
//        if(l <= r) upd(1, 1, m, l, r, x);
//        else upd(1, 1, m, l, m, x), upd(1, 1, m, 1, r, x);
        if(l <= r) {
            for(ll i = l; i <= r; i++) {
                cur[p[i]] += x;
            }
        }
        else {
            for(ll i = l; i <= m; i++) {
                cur[p[i]] += x;
            }
            for(ll i = 1; i <= r; i++) {
                cur[p[i]] += x;
            }
        }
    }
    for(ll i = 1; i <= n; i++) {
        if(cur[i] >= a[i] && !(~ans[i])) ans[i] = q;
//        cout << cur[i] << " ";
    }
//    cout << "\n";
    for(ll i = 1; i <= n; i++) {
        cout << (~ans[i] ? to_string(ans[i]) : "NIE") << "\n";
    }
}

int main(/*Уверенно*/) {
ios_base::sync_with_stdio(0);
    cin.tie(0);
/*
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
*/
//    cin >> zxc;
    while(zxc--) {
        solve();
    }
  	return 0;
}
// さよならさ いかなくちゃ
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1813 ms 800 KB Output is correct
2 Execution timed out 6032 ms 1272 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2870 ms 936 KB Output is correct
2 Correct 2905 ms 940 KB Output is correct
3 Execution timed out 6041 ms 1228 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3413 ms 836 KB Output is correct
2 Execution timed out 6084 ms 1228 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4729 ms 716 KB Output is correct
2 Execution timed out 6093 ms 972 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6075 ms 5016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6034 ms 4684 KB Time limit exceeded
2 Halted 0 ms 0 KB -