Submission #1019159

# Submission time Handle Problem Language Result Execution time Memory
1019159 2024-07-10T14:23:07 Z ttamx Pyramid Base (IOI08_pyramid_base) C++17
0 / 100
1702 ms 93204 KB
#include<bits/stdc++.h>

using namespace std;

const int N=1e6+5;
const int INF=INT_MAX/2;

int n,m,b,p;
vector<tuple<int,int,int>> add[N],del[N];

struct SegTree{
    int n,log;
    int t[2*N],lz[2*N];
    void init(int _n){
        n=_n+(_n&1);
        for(log=0;(1<<log)<n;log++);
    }
    void apply(int i,int v){
        t[i]+=v,lz[i]+=v;
    }
    void push(int i){
        apply(i<<1,lz[i]);
        apply(i<<1|1,lz[i]);
        lz[i]=0;
    }
    void pull(int i){
        t[i]=min(t[i<<1],t[i<<1|1]);
    }
    void build(){
        for(int i=1;i<2*n;i++)t[i]=lz[i]=0;
    }
    void update(int l,int r,int v){
        if(l>r)return;
        l+=n-1,r+=n;
        for(int i=log;i>=1;i--){
            if(((l>>i)<<i)!=l)push(l>>i);
            if(((r>>i)<<i)!=r)push((r-1)>>i);
        }
        for(int l2=l,r2=r;l2<r2;l2>>=1,r2>>=1){
            if(l2&1)apply(l2++,v);
            if(r2&1)apply(--r2,v);
        }
        for(int i=1;i<=log;i++){
            if(((l>>i)<<i)!=l)pull(l>>i);
            if(((r>>i)<<i)!=r)pull((r-1)>>i);
        }
    }
}seg;

bool check(int k){
    seg.build();
    seg.update(1,k-1,INF);
    for(int i=1;i<k;i++)for(auto [l,r,v]:add[i])seg.update(max(l,k),r+k-1,v);
    for(int i=k;i<=m;i++){
        for(auto [l,r,v]:add[i])seg.update(max(l,k),r+k-1,v);
        for(auto [l,r,v]:del[i-k])seg.update(max(l,k),r+k-1,-v);
        if(seg.t[1]<=b)return true;
    }
    return false;
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> m >> n >> b >> p;
    for(int i=0;i<p;i++){
        int x1,y1,x2,y2,c;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        add[x1].emplace_back(y1,y2,c);
        del[x2].emplace_back(y1,y2,c);
    }
    int l=0,r=min(n,m);
    while(l<r){
        int m=(l+r+1)/2;
        if(check(m))l=m;
        else r=m-1;
    }
    cout << l;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 50520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 50524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 50520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 50524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 54876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 62552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 63320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 51036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 55900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 64852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 65108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 65628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 801 ms 79084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1238 ms 86608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1702 ms 93204 KB Output isn't correct
2 Halted 0 ms 0 KB -