# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
866623 |
2023-10-26T14:19:54 Z |
asdfghjk |
Meteors (POI11_met) |
C++14 |
|
600 ms |
65536 KB |
/// tree bends in youth
/// 24 .10.2023
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N =3e5+ 5;
const ll NN =2e6 + 5;
const ll INF = -1e1;
const ll MOD = 1e9 + 7;
const ll LG = 18;
int z[N],x[N],c[N];
ll t[4 * N],p[4 * N],b[N];
pair<int,int> seq[N];
set <int> MID[N],rg[N];
int ok[N];
void build(int v,int l,int r){
p[v] = 0;
if(l == r){
t[v] = 0;
return;
}
int mid = (l + r) / 2;
build(v+v,l,mid);
build(v+v+1,mid+1,r);
}
void push(int v,int l,int r){
if(p[v] > 0){
if(l != r){
p[v+v] += p[v];
p[v+v+1] += p[v];
}
else{
t[v] +=p[v];
}
p[v] = 0;
}
}
void upd(int v,int l,int r,int ql,int qr,int x){
push(v,l,r);
if(l >= ql && qr >= r){
p[v] += x;
push(v,l,r);
return;
}
if(qr < l || r < ql)return;
int mid = (l + r) / 2;
upd(v+v,l,mid,ql,qr,x);
upd(v+v+1,mid+1,r,ql,qr,x);
}
int get(int v,int l,int r,int x){
push(v,l,r);
if(l == r)return t[v];
int mid = (l + r) / 2;
if(x <= mid)return get(v+v,l,mid,x);
else return get(v+v+1,mid + 1,r,x);
}
void solve(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= m;i++){
int u;cin >> u;
rg[u].insert(i);
}
for(int i= 1;i <= n;i++){
cin >> b[i];
}
int q;
cin >> q;
for(int i = 1;i <=q;i++){
cin >> z[i] >> x[i] >> c[i];
}
for(int i = 1;i <= n;i++){
seq[i] = {1,q};
}
int tt = 19;
while(tt--){
for(int i = 1;i <= n;i++){
int md = (seq[i].F + seq[i].S) / 2;
MID[md].insert(i);
}
build(1,1,m);
for(int i = 1;i <= q;i++){
if(z[i] > x[i]){
upd(1,1,m,1,x[i],c[i]);
upd(1,1,m,z[i],m,c[i]);
}
else{
upd(1,1,m,z[i],x[i],c[i]);
}
for(int to : MID[i]){
ll sum= 0;
for(int d : rg[to]){
sum += get(1,1,m,d);
if(sum >= b[to])break;
}
if(sum >= b[to]){
ok[to] = 1;
seq[to].S= i;
}
else {
seq[to].F = i + 1;
}
}
}
for(int i = 1;i <= q;i++){
MID[i].clear();
}
}
for(int i = 1;i<=n;i++){
if(seq[i].F <= q){
cout << seq[i].F << '\n';
}
else{
cout << "NIE\n";
}
}
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ll abd= 1;
// cin >> abd;
for(ll i = 1;i <= abd;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
Compilation message
met.cpp:123:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
123 | main (){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
41816 KB |
Output is correct |
2 |
Correct |
14 ms |
41564 KB |
Output is correct |
3 |
Correct |
14 ms |
41560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
41572 KB |
Output is correct |
2 |
Correct |
13 ms |
41564 KB |
Output is correct |
3 |
Correct |
14 ms |
41564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
416 ms |
46168 KB |
Output is correct |
2 |
Correct |
572 ms |
47188 KB |
Output is correct |
3 |
Correct |
534 ms |
46672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
490 ms |
46160 KB |
Output is correct |
2 |
Correct |
514 ms |
46344 KB |
Output is correct |
3 |
Correct |
600 ms |
47152 KB |
Output is correct |
4 |
Correct |
140 ms |
46632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
46140 KB |
Output is correct |
2 |
Correct |
401 ms |
47148 KB |
Output is correct |
3 |
Correct |
235 ms |
41304 KB |
Output is correct |
4 |
Correct |
513 ms |
46740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
471 ms |
45916 KB |
Output is correct |
2 |
Correct |
447 ms |
46420 KB |
Output is correct |
3 |
Correct |
475 ms |
45984 KB |
Output is correct |
4 |
Correct |
563 ms |
47148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
141 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
142 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |