답안 #870016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870016 2023-11-06T16:02:38 Z vjudge1 Meteors (POI11_met) C++17
0 / 100
3967 ms 65536 KB
// KCPC - 50.6907
#include <bits/stdc++.h>

#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define md(l, r) ((l + r) >> 1)
#define rv(x) ((x << 1) + 1)
#define lv(x) (x << 1)
#define pb emplace_back
#define elif else if
#define uns unsigned
#define emp empty()
#define nll nullptr
#define S second
#define F first

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef pair < int, int > pi;
typedef pair < ldb, ldb > pldb;
typedef vector < pair < ll, ll > > vpll;
typedef vector < pair < int, int > > vpi;

const int N = 3e5 + 11;
const int M = 1e4 + 123;
const int mod = 1e9 + 7;
const int mxlg = 19;
const int K = 20;
const int P = 31;
const ll inf = 1e9 + 10;

//mt19937 rnd(07062006);

ll n, m, q, s;
ll a[N], b[N], l[N], r[N], x[N];
ll al[N], ar[N];
ll t[4 * N], z[4 * N];

vll v[N], vq[N];

void push(ll v, ll l, ll r){
	if(!z[v]) return;
	if(l != r) z[lv(v)] += z[v], z[rv(v)] += z[v];
	t[v] += z[v] * (r - l + 1), z[v] = 0;
}

void upd(ll tl, ll tr, ll x, ll v = 1, ll l = 1, ll r = m){
	push(v, l, r);
	if(r < tl || tr < l) return;
	if(tl <= l && r <= tr){
		z[v] += x;
		push(v, l, r);
		return;
	}
	ll m = md(l, r);
	upd(tl, tr, x, lv(v), l, m);
	upd(tl, tr, x, rv(v), m + 1, r);
	t[v] = t[lv(v)] + t[rv(v)];
}

ll get(ll tl, ll tr, ll v = 1, ll l = 1, ll r = m){
	if(r < tl || tr < l) return 0;
	if(tl <= l && r <= tr) return t[v];
	ll m = md(l, r);
	return get(tl, tr, lv(v), l, m) + 
		   get(tl, tr, rv(v), m + 1, r);
}

void output(){
	cin >> n >> m;
	for(int i = 1; i <= m; i++) cin >> b[i], v[b[i]].pb(i);
	for(int i = 1; i <= n; i++) cin >> a[i];
	cin >> q;
	for(int i = 1; i <= n; i++){
		al[i] = 1;
		ar[i] = q + 1;
	}
	for(int i = 1; i <= q; i++) cin >> l[i] >> r[i] >> x[i];
	bool ok = 1;
	while(ok){
		ok = 0;
		memset(t, 0, sizeof(t));
		memset(z, 0, sizeof(z));
		for(int i = 1; i <= n; i++)
			if(al[i] != ar[i])
				vq[md(al[i], ar[i])].pb(i);
		for(int i = 1; i <= q; i++){
			if(l[i] <= r[i]) upd(l[i], r[i], x[i]);
			else upd(l[i], m, x[i]), upd(1, r[i], x[i]);
			for(auto id : vq[i]){
				ok = 1, s = 0;
				for(auto x : v[id]){
					s += get(x, x);
					if(s >= a[id]) break;
				}
				if(s >= a[id]) ar[id] = i;
				else al[id] = i + 1;
			}
			vq[i].clear();
		}
	}
	for(int i = 1; i <= n; i++){
		if(al[i] == q + 1) cout << "NIE\n";
		else cout << al[i] << '\n';
	}
}

const bool cases = 0;

signed main(){
//  file("disrupt");
    adiyer();
    int tt = 1;
    if(cases) cin >> tt;
    for(int i = 1; i <= tt; i++){
//      cout << "Case " << i << ":\n";
        output();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 45804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 45816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 447 ms 47900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 513 ms 49184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 224 ms 47956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 546 ms 47360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3449 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3967 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -