Submission #588118

# Submission time Handle Problem Language Result Execution time Memory
588118 2022-07-02T17:42:40 Z Bench0310 Pyramid Base (IOI08_pyramid_base) C++17
70 / 100
5000 ms 121396 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N=1000005;
ll tree[4*N];
ll lazy[4*N];

void pull(int idx){tree[idx]=min(tree[2*idx],tree[2*idx+1]);}
void apply(int idx,ll x){tree[idx]+=x; lazy[idx]+=x;}
void push(int idx){for(int i=0;i<2;i++)apply(2*idx+i,lazy[idx]); lazy[idx]=0;}

void update(int idx,int l,int r,int ql,int qr,ll x)
{
    if(ql>qr) return;
    if(l==ql&&r==qr) apply(idx,x);
    else
    {
        int m=(l+r)/2;
        push(idx);
        update(2*idx,l,m,ql,min(qr,m),x);
        update(2*idx+1,m+1,r,max(ql,m+1),qr,x);
        pull(idx);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> m >> n;
    int b,p;
    cin >> b >> p;
    vector<array<int,5>> obstacles(p);
    for(auto &[x1,y1,x2,y2,c]:obstacles) cin >> x1 >> y1 >> x2 >> y2 >> c;
    int l=0,r=min(n,m)+1;
    vector<array<ll,3>> v[m+2];
    const ll inf=(1ll<<32);
    while(l<r-1)
    {
        int len=(l+r)/2;
        bool ok=0;
        auto add=[&](int x1,int y1,int x2,int y2,ll c)
        {
            v[x1].push_back({y1,y2,c});
            v[x2+1].push_back({y1,y2,-c});
        };
        for(auto [x1,y1,x2,y2,c]:obstacles) add(max(1,x1-len+1),max(1,y1-len+1),x2,y2,c);
        if(len>1)
        {
            add(1,n-len+2,m,n,inf);
            add(m-len+2,1,m,n,inf);
        }
        for(int x=1;x<=m+1;x++)
        {
            for(auto [y1,y2,c]:v[x]) update(1,1,n,y1,y2,c);
            if(x<=m) ok|=(tree[1]<=b);
            v[x].clear();
        }
        if(ok) l=len;
        else r=len;
    }
    cout << l << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 7124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 39368 KB Output is correct
2 Correct 127 ms 54652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 55136 KB Output is correct
2 Correct 109 ms 40108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1684 KB Output is correct
2 Correct 59 ms 1984 KB Output is correct
3 Correct 47 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 10048 KB Output is correct
2 Correct 328 ms 10780 KB Output is correct
3 Correct 244 ms 10924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 789 ms 61972 KB Output is correct
2 Correct 127 ms 28764 KB Output is correct
3 Correct 275 ms 35248 KB Output is correct
4 Correct 972 ms 65948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1065 ms 64896 KB Output is correct
2 Correct 964 ms 68324 KB Output is correct
3 Correct 780 ms 59848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1040 ms 63184 KB Output is correct
2 Correct 1411 ms 70424 KB Output is correct
3 Correct 1316 ms 70104 KB Output is correct
4 Correct 1248 ms 70528 KB Output is correct
5 Correct 1268 ms 70460 KB Output is correct
6 Correct 942 ms 59316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5034 ms 103328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5021 ms 112020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5047 ms 121396 KB Time limit exceeded
2 Halted 0 ms 0 KB -