Submission #588125

# Submission time Handle Problem Language Result Execution time Memory
588125 2022-07-02T17:51:18 Z Bench0310 Pyramid Base (IOI08_pyramid_base) C++17
35 / 100
5000 ms 92312 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

void pull(int idx){tree[idx]=min(tree[2*idx],tree[2*idx+1]);}
void apply(int idx,int 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,int 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<int,3>> v[m+2];
    while(l<r-1)
    {
        int len=(l+r)/2;
        bool ok=0;
        int limm=m-len+1;
        int limn=n-len+1;
        auto add=[&](int x1,int y1,int x2,int y2,int c)
        {
            v[x1].push_back({y1,y2,1});
            v[x2+1].push_back({y1,y2,-1});
        };
        for(auto [x1,y1,x2,y2,c]:obstacles) add(max(1,x1-len+1),max(1,y1-len+1),min(x2,limm),min(y2,limn),c);
        for(int x=1;x<=limm+1;x++)
        {
            for(auto [y1,y2,c]:v[x]) update(1,1,limn,y1,y2,c);
            if(x<=limm) 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 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 5144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 29944 KB Output is correct
2 Correct 114 ms 40772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 40764 KB Output is correct
2 Correct 44 ms 31904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1880 KB Output is correct
2 Incorrect 7 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 210 ms 8296 KB Output is correct
2 Incorrect 33 ms 7564 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 314 ms 39824 KB Output is correct
2 Correct 113 ms 28756 KB Output is correct
3 Correct 201 ms 19452 KB Output is correct
4 Incorrect 50 ms 37964 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 584 ms 50684 KB Output is correct
2 Incorrect 212 ms 41184 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 352 ms 42756 KB Output is correct
2 Incorrect 673 ms 52576 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5085 ms 79916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5087 ms 85668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5091 ms 92312 KB Time limit exceeded
2 Halted 0 ms 0 KB -