# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865584 |
2023-10-24T11:20:24 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
5044 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=4e5+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;
}c[N];
vector <int> q[N], pp[N];
int p[N*4];
void push(int v, int tl, int tr){
if(!p[v])return;
if(tl < tr){
p[v+v] += p[v];
p[v+v+1] += p[v];
p[v] = 0;
}
}
void build(int v=1, int tl=1, int tr=m){
p[v] = 0;
if(tl == tr)return;
build(TL);
build(TR);
}
void upd(int l, int r, int x, int v=1, int tl=1, int tr=m){
push(v, tl, tr);
if(DA){
p[v] += x;
push(v, tl, tr);
return;
}
if(NET)return;
upd(l, r, x, TL);
upd(l, r, x, TR);
}
int get(int pos, int v=1, int tl=1, int tr=m){
push(v, tl, tr);
if(tl == tr)return p[v];
if(pos <= tm)return get(pos, TL);
else return get(pos, TR);
}
void AlemAmenov(){
cin >> n >> m;
for(int i=1; i <= m; i++){
cin >> a[i];
pp[a[i]].pb(i);
}
for(int i=1; i <= n; i++){
cin >> b[i];
}
cin >> 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++){
c[i].l = 1;
c[i].r = k;
}
for(int gg=1; gg <= 30; gg++){
for(int i=1; i <= m; i++){
q[i].clear();
}
for(int i=1; i <= n; i++){
if(c[i].l <= c[i].r){
int md = (c[i].l + c[i].r)/2;
q[md].pb(i);
}
}
build();
for(int i=1; i <= k; i++){
int l = f[i].l;
int r = f[i].r;
if(f[i].l <= f[i].r){
upd(l, r, f[i].p);
}
else {
upd(1, r, f[i].p);
upd(l, m, f[i].p);
}
for(int j : q[i]){
int f=0;
for(int it : pp[j]){
f += get(it);
if(b[j] <= f)break;
}
if(f < b[j])c[j].l = i+1;
else c[j].r = i-1;
}
}
}
for(int i=1; i <= n; i++){
if(c[i].l <= k)cout << c[i].l << '\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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
26972 KB |
Output is correct |
2 |
Correct |
14 ms |
27228 KB |
Output is correct |
3 |
Correct |
14 ms |
27212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
27228 KB |
Output is correct |
2 |
Correct |
13 ms |
27220 KB |
Output is correct |
3 |
Correct |
14 ms |
27224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
601 ms |
30800 KB |
Output is correct |
2 |
Correct |
707 ms |
33612 KB |
Output is correct |
3 |
Correct |
674 ms |
32716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
671 ms |
32016 KB |
Output is correct |
2 |
Correct |
671 ms |
32080 KB |
Output is correct |
3 |
Correct |
685 ms |
33968 KB |
Output is correct |
4 |
Correct |
101 ms |
32084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
304 ms |
31180 KB |
Output is correct |
2 |
Correct |
503 ms |
34064 KB |
Output is correct |
3 |
Incorrect |
369 ms |
27472 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
644 ms |
29940 KB |
Output is correct |
2 |
Correct |
604 ms |
31932 KB |
Output is correct |
3 |
Correct |
642 ms |
30320 KB |
Output is correct |
4 |
Correct |
693 ms |
35084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5044 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5027 ms |
64708 KB |
Output is correct |
2 |
Correct |
1755 ms |
45136 KB |
Output is correct |
3 |
Incorrect |
1438 ms |
31464 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |