Submission #863311

# Submission time Handle Problem Language Result Execution time Memory
863311 2023-10-20T03:01:31 Z imarn Meteors (POI11_met) C++14
74 / 100
6000 ms 54276 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<ll,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;
    while(1){
        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};
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 20 ms 33372 KB Output is correct
2 Correct 21 ms 33372 KB Output is correct
3 Correct 23 ms 33380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 33372 KB Output is correct
2 Correct 22 ms 33368 KB Output is correct
3 Correct 26 ms 33368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 507 ms 35232 KB Output is correct
2 Correct 563 ms 37560 KB Output is correct
3 Correct 586 ms 36884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 529 ms 36600 KB Output is correct
2 Correct 592 ms 36312 KB Output is correct
3 Correct 610 ms 37616 KB Output is correct
4 Correct 154 ms 35668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 309 ms 35568 KB Output is correct
2 Correct 505 ms 38128 KB Output is correct
3 Correct 220 ms 34152 KB Output is correct
4 Correct 566 ms 37480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 553 ms 34820 KB Output is correct
2 Correct 591 ms 36412 KB Output is correct
3 Correct 499 ms 35152 KB Output is correct
4 Correct 589 ms 38632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6032 ms 54276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5327 ms 53524 KB Output is correct
2 Incorrect 2240 ms 41688 KB Output isn't correct
3 Halted 0 ms 0 KB -