Submission #1019131

# Submission time Handle Problem Language Result Execution time Memory
1019131 2024-07-10T14:00:21 Z ttamx Pyramid Base (IOI08_pyramid_base) C++17
80 / 100
5000 ms 96336 KB
#include<bits/stdc++.h>

using namespace std;

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

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

struct SegTree{
    int t[K],lz[K];
    void apply(int i,int v){
        t[i]+=v,lz[i]+=v;
    }
    void push(int i){
        apply(i*2,lz[i]);
        apply(i*2+1,lz[i]);
        lz[i]=0;
    }
    void build(int l,int r,int i){
        t[i]=0,lz[i]=0;
        if(l==r)return;
        int m=(l+r)/2;
        build(l,m,i*2);
        build(m+1,r,i*2+1);
    }
    void build(){
        build(1,n,1);
    }
    void update(int l,int r,int i,int x,int y,int v){
        if(y<l||r<x)return;
        if(x<=l&&r<=y)return apply(i,v);
        int m=(l+r)/2;
        push(i);
        update(l,m,i*2,x,y,v);
        update(m+1,r,i*2+1,x,y,v);
        t[i]=min(t[i*2],t[i*2+1]);
    }
    void update(int x,int y,int v){
        update(1,n,1,x,y,v);
    }
    int query(int l,int r,int i,int x,int y){
        if(y<l||r<x)return INF;
        if(x<=l&&r<=y)return t[i];
        int m=(l+r)/2;
        push(i);
        return min(query(l,m,i*2,x,y),query(m+1,r,i*2+1,x,y));
    }
    int query(int x,int y){
        return query(1,n,1,x,y);
    }
}seg;

bool check(int k){
    seg.build();
    for(int i=1;i<=m;i++){
        for(auto [l,r,v]:add[i])seg.update(l,r+k-1,v);
        if(i>=k)for(auto [l,r,v]:del[i-k])seg.update(l,r+k-1,-v);
        if(i>=k&&seg.query(k,n)<=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 Correct 23 ms 47196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 47192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 47448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 47708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 49552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 319 ms 63896 KB Output is correct
2 Correct 2693 ms 63904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1599 ms 63912 KB Output is correct
2 Correct 564 ms 63836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 47964 KB Output is correct
2 Correct 53 ms 47960 KB Output is correct
3 Correct 47 ms 47952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 50708 KB Output is correct
2 Correct 277 ms 50524 KB Output is correct
3 Correct 287 ms 50520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 520 ms 65632 KB Output is correct
2 Correct 62 ms 48980 KB Output is correct
3 Correct 112 ms 65048 KB Output is correct
4 Correct 1138 ms 65688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 911 ms 66092 KB Output is correct
2 Correct 3250 ms 65920 KB Output is correct
3 Correct 505 ms 66144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 781 ms 66640 KB Output is correct
2 Correct 3376 ms 66416 KB Output is correct
3 Correct 3455 ms 66388 KB Output is correct
4 Correct 3561 ms 66388 KB Output is correct
5 Correct 3734 ms 66412 KB Output is correct
6 Correct 401 ms 66388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3883 ms 80968 KB Output is correct
2 Correct 500 ms 60948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5035 ms 88708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5022 ms 96336 KB Time limit exceeded
2 Halted 0 ms 0 KB -