답안 #865130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865130 2023-10-24T05:49:57 Z vjudge1 Meteors (POI11_met) C++17
24 / 100
6000 ms 65536 KB
//gm  --- akezhon
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NET r < tl || tr < l
#define double long double
using namespace std;
const int N=3e5+7;
const int M=1e9+7;
const int inf=1e9;
int n, m, k;
int a[N];
int b[N];
struct qu{
	int l, r, p;
}f[N];
struct lol{
	int l, r, m, ans;
}c[N];
int sz;
int root[N];
struct DO{
	int l, r, sum;
}t[N*60];
int upd(int v, int pos, int tl=1, int tr=m){
	int nv = ++sz;
	t[nv] = t[v];
	if(tl == tr){
		t[nv].sum++;
		return nv;
	}
	if(pos <= tm)t[nv].l = upd(t[nv].l, pos, tl, tm);
	else t[nv].r = upd(t[nv].r, pos, tm+1, tr);
	t[nv].sum = t[t[nv].l].sum + t[t[nv].r].sum;
	return nv;
}
int get(int v, int l, int r, int tl=1, int tr=m){
	if(NET)return 0;
	if(DA)return t[v].sum;
	return get(t[v].l, l, r, tl, tm) + get(t[v].r, l, r, tm+1, tr);
}
void AlemAmenov(){
	
	cin >> n >> m;
	for(int i=1; i <= m; i++){
		cin >> a[i];
		root[a[i]] = upd(root[a[i]], i);
	}
	for(int i=1; i <= n; i++){
		cin >> b[i];
	}
	cin >> k;
	for(int i=1; i <= n; i++){
		c[i].l = 1;
		c[i].r = k;
	}
	for(int i=1; i <= k; i++){
		cin >> f[i].l >> f[i].r >> f[i].p;
	}
	for(int i=1; i <= n; i++){
		int cnt=0;
		for(int j=1; j <= k; j++){
			if(f[j].l <= f[j].r){
				cnt += get(root[i], f[j].l, f[j].r) * f[j].p;
			}
			else {
				cnt += get(root[i], f[j].l, m) * f[j].p;
				cnt += get(root[i], 1, f[j].r) * f[j].p;
			}
			if(b[i] <= cnt){
				c[i].ans = j;
				break;
			}
		}
	}
	
	for(int i=1; i <= n; i++){
		if(c[i].ans)cout << c[i].ans << '\n';
		else cout << "NIE\n";
	}
	
}
signed main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	// freopen("promote.in", "r", stdin);
	// freopen("promote.out", "w", stdout);
	int RealName=1;
	// cin >> RealName;
	// int C=0;
	while(RealName--){
		// cout << "Case " << ++C << ":\n";
		AlemAmenov();
	}

return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 8868 KB Output is correct
2 Correct 74 ms 8796 KB Output is correct
3 Correct 16 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 8792 KB Output is correct
2 Correct 3 ms 8792 KB Output is correct
3 Correct 75 ms 8872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6041 ms 29532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6062 ms 29532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6044 ms 29532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 518 ms 29384 KB Output is correct
2 Execution timed out 6034 ms 29528 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 45 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 45 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -