답안 #914465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914465 2024-01-22T08:21:25 Z abcvuitunggio Pyramid Base (IOI08_pyramid_base) C++17
70 / 100
5000 ms 145728 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int M=1000001,P=400001;
int m,n,b,p,x[P],y[P],u[P],v[P],c[P],st[M*4],lazy[M*4];
vector <int> ve[M+1];
void down(int node, int l, int r){
    if (!lazy[node]||l==r)
        return;
    st[node<<1]+=lazy[node];
    st[node<<1|1]+=lazy[node];
    lazy[node<<1]+=lazy[node];
    lazy[node<<1|1]+=lazy[node];
    lazy[node]=0;
}
void update(int node, int l, int r, int u, int v, int val){
    if (l>v||r<u)
        return;
    if (l>=u&&r<=v){
        st[node]+=val;
        lazy[node]+=val;
        return;
    }
    down(node,l,r);
    int mid=(l+r)>>1;
    update(node<<1,l,mid,u,v,val);
    update(node<<1|1,mid+1,r,u,v,val);
    st[node]=min(st[node<<1],st[node<<1|1]);
}
bool check(int sz){
    for (int i=1;i<=m+1;i++)
        ve[i].clear();
    for (int i=1;i<=n*4;i++)
        st[i]=lazy[i]=0;
    for (int i=1;i<=p;i++){
        int X=max(x[i]-sz+1,1LL);
        ve[X].push_back(i);
        ve[u[i]+1].push_back(-i);
    }
    for (int i=1;i<=m-sz+1;i++){
        for (int j:ve[i])
            update(1,1,n-sz+1,max(y[abs(j)]-sz+1,1LL),v[abs(j)],c[abs(j)]*(j<0?-1:1));
        if (st[1]<=b)
            return true;
    }
    return false;
}
int32_t main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> m >> n >> b >> p;
    for (int i=1;i<=p;i++)
        cin >> x[i] >> y[i] >> u[i] >> v[i] >> c[i];
    int l=1,r=min(m,n),kq=0;
    while (l<=r){
        int mid=(l+r)>>1;
        if (check(mid)){
            kq=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    cout << kq;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 37468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 37876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 37628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 37724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 44124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 214 ms 95428 KB Output is correct
2 Correct 277 ms 95344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 296 ms 95372 KB Output is correct
2 Correct 211 ms 95068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 38068 KB Output is correct
2 Correct 48 ms 37980 KB Output is correct
3 Correct 42 ms 38100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 48212 KB Output is correct
2 Correct 223 ms 48876 KB Output is correct
3 Correct 183 ms 48812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 391 ms 104392 KB Output is correct
2 Correct 76 ms 46420 KB Output is correct
3 Correct 188 ms 99960 KB Output is correct
4 Correct 655 ms 108160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 629 ms 107216 KB Output is correct
2 Correct 1177 ms 109720 KB Output is correct
3 Correct 301 ms 102036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 536 ms 105276 KB Output is correct
2 Correct 1422 ms 112496 KB Output is correct
3 Correct 1389 ms 112056 KB Output is correct
4 Correct 1536 ms 112196 KB Output is correct
5 Correct 1424 ms 112204 KB Output is correct
6 Correct 267 ms 101664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5074 ms 137844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5005 ms 143400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5060 ms 145728 KB Time limit exceeded
2 Halted 0 ms 0 KB -