답안 #684497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684497 2023-01-21T11:05:03 Z bachhoangxuan Meteors (POI11_met) C++17
74 / 100
902 ms 65536 KB
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define pii pair<int,int>
const int inf=1e18;
const int mod=998244353;
const int maxn=300005;
const int maxl=20;
const int maxa=1000005;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
struct qry{
    int l,r,val;
};
int n,m,q,a[maxn],p[maxn],ans[maxn];
vector<int> x[maxn],ss[maxn];
qry que[maxn];
namespace BIT{
    int bit[maxn];
    void update(int l,int r,int val){
        for(int i=l;i<=m;i+=(i&(-i))) bit[i]+=val;
        for(int i=r+1;i<=m;i+=(i&(-i))) bit[i]-=val;
    }
    void up(int l,int r,int val){
        if(l>r){update(l,m,val);update(1,r,val);}
        else update(l,r,val);
    }
    int query(int x){
        int res=0;
        for(int i=x;i>=1;i-=(i&(-i))) res+=bit[i];
        return res;
    }
}
void cal(int l,int r){
    int mid=(l+r)>>1,lt=(l+mid-1)>>1,rt=(mid+r+1)>>1;
    for(int v:ss[mid]){
        int sum=0;
        for(int d:x[v]) sum=min(sum+BIT::query(d),inf);
        if(sum>=p[v]) ans[v]=mid;
        if(sum>=p[v] && l<mid) ss[lt].push_back(v);
        else if(sum<p[v] && r>mid) ss[rt].push_back(v);
    }
    if(r>mid){
        for(int i=mid+1;i<=rt;i++) BIT::up(que[i].l,que[i].r,que[i].val);
        cal(mid+1,r);
        for(int i=mid+1;i<=rt;i++) BIT::up(que[i].l,que[i].r,-que[i].val);
    }
    if(l<mid){
        for(int i=lt+1;i<=mid;i++) BIT::up(que[i].l,que[i].r,-que[i].val);
        cal(l,mid-1);
        for(int i=lt+1;i<=mid;i++) BIT::up(que[i].l,que[i].r,que[i].val);
    }
}
void solve(){
    cin >> n >> m;
    for(int i=1;i<=m;i++){cin >> a[i];x[a[i]].push_back(i);}
    for(int i=1;i<=n;i++) cin >> p[i];
    cin >> q;
    for(int i=1;i<=q;i++) cin >> que[i].l >> que[i].r >> que[i].val;
    int mid=(1+q)>>1;
    for(int i=1;i<=n;i++) ss[mid].push_back(i);
    for(int i=1;i<=mid;i++) BIT::up(que[i].l,que[i].r,que[i].val);
    cal(1,q);
    for(int i=1;i<=n;i++){
        if(ans[i]) cout << ans[i] << '\n';
        else cout << "NIE\n";
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t=1;//cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14576 KB Output is correct
3 Correct 9 ms 14440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 14556 KB Output is correct
2 Correct 9 ms 14548 KB Output is correct
3 Correct 9 ms 14548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 17748 KB Output is correct
2 Correct 97 ms 22092 KB Output is correct
3 Correct 80 ms 21020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 19180 KB Output is correct
2 Correct 84 ms 20284 KB Output is correct
3 Correct 95 ms 22424 KB Output is correct
4 Correct 30 ms 18548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 18264 KB Output is correct
2 Correct 83 ms 22668 KB Output is correct
3 Correct 44 ms 16356 KB Output is correct
4 Correct 82 ms 21724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 16964 KB Output is correct
2 Correct 103 ms 19148 KB Output is correct
3 Correct 65 ms 18436 KB Output is correct
4 Correct 101 ms 23900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 902 ms 49116 KB Output is correct
2 Correct 694 ms 36508 KB Output is correct
3 Correct 190 ms 22804 KB Output is correct
4 Runtime error 773 ms 65536 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 874 ms 47292 KB Output is correct
2 Correct 702 ms 34956 KB Output is correct
3 Correct 160 ms 22620 KB Output is correct
4 Runtime error 804 ms 65536 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -