답안 #761709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
761709 2023-06-20T07:26:02 Z vjudge1 Meteors (POI11_met) C++17
0 / 100
148 ms 65536 KB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
#define ll ll
using namespace std;
using ll = long long;
 
const ll N = 3e5+5 , M = 1e7+5, inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;	

ll a[N] , b[N] , l[N] , r[N] , c[N] , root[N] , sz , R[M] , L[M];
vector<ll> g[N];
ll laz[M];

ll upd(ll v, ll tl, ll tr, ll l , ll r , ll val){
	if(tl > r || tr < l) return v;
	if(l <= tl && tr <= r) {
		ll nv = sz++;
		laz[nv] = laz[v] + val;
		L[nv] = L[v];
		R[nv] = R[v];
		return nv;
	}	
	ll nv = sz++;
	ll tm = (tl + tr) >> 1;
	L[nv] = upd(L[v], tl, tm, l , r , val);
	R[nv] = upd(R[v], tm+1, tr, l , r , val);
	return nv;	
}
ll get(ll v , ll tl , ll tr , ll pos){
	if(tl == tr) return laz[v];
	ll tm = (tl+tr) >> 1;
	if(tm >= pos){
		return get(L[v],tl,tm,pos) + laz[v];
	} else {
		return get(R[v],tm+1,tr,pos) + laz[v];
	}
}
void solve(){
	sz = 1;
	ll n, m;
	cin >> n >> m;
	for(ll i = 1; i <= m; i++) cin >> a[i] , g[a[i]].push_back(i);
	for(ll i = 1; i <= n; i++) cin >> b[i];
	ll k;
	cin >> k;
	for(ll i = 1; i <= k; i++) {
		cin >> l[i] >> r[i] >> c[i];
		root[i] = root[i-1];
		if(l[i] > r[i]){
			root[i] = upd(root[i],1,m,l[i],m,c[i]);
			root[i] = upd(root[i],1,m,1,r[i],c[i]);
		} else {
			root[i] = upd(root[i],1,m,l[i],r[i],c[i]);	
		}
	}
	for(ll i = 1; i <= n; i++){
		if(g[i].size() == 0){
			cout << "NIE\n";
			continue;
		}
		ll res = 0;
		for(ll l = 1 , r = k; l <= r;){
			ll md = (l+r) >> 1;
			ll sum = 0;
			for(ll x : g[i]) {
				sum += get(root[md],1,m,x);
			}
			if(sum >= b[i]){
				res = md;
				r = md-1;
			} else {
				l = md+1;
			}
		}
		if(res == 0){
			cout << "NIE\n";
		} else {
			cout << res << "\n";
		}
		
	}
}
/*

*/
signed main(){
	ios;
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 8012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 97 ms 57672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 114 ms 58288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 36008 KB Output is correct
2 Incorrect 94 ms 55216 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 141 ms 61828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 148 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 142 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -