답안 #870168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870168 2023-11-07T06:46:01 Z vjudge1 Meteors (POI11_met) C++17
87 / 100
3543 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 + 3;
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);

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

vi v[N], vq[N];

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

ll get(ll k, ll v = 1, ll l = 1, ll r = m){
	if(l == r) return t[v];
	ll m = md(l, r);
	if(k <= m) return get(k, lv(v), l, m) + t[v]; 
	else return get(k, rv(v), m + 1, r) + t[v];
}

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));
		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);
					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 Correct 10 ms 31324 KB Output is correct
2 Correct 11 ms 31452 KB Output is correct
3 Correct 10 ms 31324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 31324 KB Output is correct
2 Correct 9 ms 31324 KB Output is correct
3 Correct 10 ms 31420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 232 ms 32028 KB Output is correct
2 Correct 340 ms 34000 KB Output is correct
3 Correct 299 ms 33444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 33112 KB Output is correct
2 Correct 282 ms 32984 KB Output is correct
3 Correct 305 ms 33952 KB Output is correct
4 Correct 69 ms 32844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 32488 KB Output is correct
2 Correct 209 ms 34388 KB Output is correct
3 Correct 130 ms 31436 KB Output is correct
4 Correct 289 ms 33940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 31824 KB Output is correct
2 Correct 247 ms 33104 KB Output is correct
3 Correct 266 ms 31996 KB Output is correct
4 Correct 320 ms 35244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2711 ms 46996 KB Output is correct
2 Correct 938 ms 32864 KB Output is correct
3 Correct 674 ms 31572 KB Output is correct
4 Correct 3543 ms 65536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2753 ms 44232 KB Output is correct
2 Correct 790 ms 32720 KB Output is correct
3 Incorrect 560 ms 31500 KB Output isn't correct
4 Halted 0 ms 0 KB -