# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863308 |
2023-10-20T02:57:05 Z |
imarn |
Meteors (POI11_met) |
C++14 |
|
4894 ms |
53824 KB |
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define ll long long
#define s second
using namespace std;
const int N=3e5+5;
ll t[4*N]{0},lz[4*N]{0};
void push(int i,int l,int r){
t[i]+=lz[i];
if(l<r){
lz[2*i]+=lz[i];
lz[2*i+1]+=lz[i];
}lz[i]=0;
}
void update(int i,int l,int r,int tl,int tr,ll v){
push(i,l,r);
if(r<tl||l>tr)return;
if(r<=tr&&l>=tl){
lz[i]+=v;push(i,l,r);
return;
}int m=(l+r)>>1;
update(2*i,l,m,tl,tr,v);update(2*i+1,m+1,r,tl,tr,v);
t[i]=max(t[2*i],t[2*i+1]);
}
ll qr(int i,int l,int r,int idx){
push(i,l,r);
if(r<idx||l>idx)return 0;
if(l==r)return t[i];
int m=(l+r)>>1;
return max(qr(2*i,l,m,idx),qr(2*i+1,m+1,r,idx));
}
vector<int>g[N];
vector<int>now[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n,m;cin>>n>>m;
ll a[n+1]={0},b[m+1],c[n+1]={0};
for(int i=1;i<=m;i++)cin>>b[i],g[b[i]].pb(i);
for(int i=1;i<=n;i++)cin>>c[i];
int k;cin>>k;
pair<int,pair<int,int>>q[k+1];
for(int i=1;i<=k;i++)cin>>q[i].s.f>>q[i].s.s>>q[i].f;
int l[n+1],r[n+1];
for(int i=1;i<=n;i++)l[i]=1,r[i]=k+1;
int nw=0;int pre=0;
while(1){
pre=nw;nw=1-nw;
memset(t,0,sizeof t);
memset(lz,0,sizeof lz);
int cnt=0;
for(int i=1;i<=n;i++){
if(l[i]==r[i])continue;
cnt++;now[(l[i]+r[i])/2].pb(i);
}if(cnt==0)break;
for(int i=1;i<=k;i++){
if(q[i].s.f<=q[i].s.s)update(1,1,m,q[i].s.f,q[i].s.s,q[i].f);
else update(1,1,m,q[i].s.f,m,q[i].f),update(1,1,m,1,q[i].s.s,q[i].f);
for(auto it : now[i]){
ll sum=0;
for(auto ij : g[it])sum+=qr(1,1,m,ij);
if(sum>=c[it])r[it]=i;
else l[it]=i+1;
}now[i].clear();
}
}for(int i=1;i<=n;i++){
if(l[i]>k)cout<<"NIE\n";
else cout<<l[i]<<"\n";
}
}
Compilation message
met.cpp: In function 'int main()':
met.cpp:38:8: warning: unused variable 'a' [-Wunused-variable]
38 | ll a[n+1]={0},b[m+1],c[n+1]={0};
| ^
met.cpp:46:18: warning: variable 'pre' set but not used [-Wunused-but-set-variable]
46 | int nw=0;int pre=0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
33372 KB |
Output is correct |
2 |
Correct |
20 ms |
33372 KB |
Output is correct |
3 |
Correct |
20 ms |
33368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
33372 KB |
Output is correct |
2 |
Correct |
23 ms |
33372 KB |
Output is correct |
3 |
Correct |
20 ms |
33400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
473 ms |
34900 KB |
Output is correct |
2 |
Correct |
539 ms |
37312 KB |
Output is correct |
3 |
Correct |
541 ms |
36788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
508 ms |
36180 KB |
Output is correct |
2 |
Correct |
521 ms |
36176 KB |
Output is correct |
3 |
Correct |
558 ms |
37536 KB |
Output is correct |
4 |
Correct |
147 ms |
35452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
300 ms |
35412 KB |
Output is correct |
2 |
Correct |
460 ms |
37716 KB |
Output is correct |
3 |
Correct |
223 ms |
33884 KB |
Output is correct |
4 |
Correct |
523 ms |
37300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
518 ms |
34648 KB |
Output is correct |
2 |
Correct |
507 ms |
36080 KB |
Output is correct |
3 |
Correct |
491 ms |
35088 KB |
Output is correct |
4 |
Correct |
554 ms |
38628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4894 ms |
53824 KB |
Output is correct |
2 |
Incorrect |
3409 ms |
40516 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4799 ms |
52324 KB |
Output is correct |
2 |
Incorrect |
2148 ms |
40500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |