답안 #914480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914480 2024-01-22T08:52:31 Z abcvuitunggio Pyramid Base (IOI08_pyramid_base) C++17
80 / 100
5000 ms 94992 KB
#include <bits/stdc++.h>
using namespace std;
const int M=1000001,P=400001;
int m,n,b,p,x[P],y[P],u[P],v[P],c[P],s=1;
unsigned int st[M*4],sum[M*4];
vector <int> ve[M+1];
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;
        sum[node]+=val;
        return;
    }
    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])+sum[node];
}
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]=sum[i]=0;
    for (int i=1;i<=p;i++){
        int X=max(x[i]-sz+1,1);
        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,1),v[abs(j)],c[abs(j)]*(j<0?-1:1));
        if (st[1]<=b)
            return true;
    }
    return false;
}
int 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];
    if (!check(1)){
        cout << 0;
        return 0;
    }
    int l=2,r=min(m,n),kq=1;
    while (l<=r){
        int mid=(l+r)>>1;
        if (check(mid)){
            kq=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    cout << kq;
}

Compilation message

pyramid_base.cpp: In function 'bool check(int)':
pyramid_base.cpp:33:18: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   33 |         if (st[1]<=b)
      |             ~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 35420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 35420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 35420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 37724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 40272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 62264 KB Output is correct
2 Correct 23 ms 62220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 227 ms 62700 KB Output is correct
2 Correct 155 ms 62288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 37812 KB Output is correct
2 Correct 41 ms 37724 KB Output is correct
3 Correct 35 ms 37720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 41812 KB Output is correct
2 Correct 170 ms 42064 KB Output is correct
3 Correct 160 ms 42320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 330 ms 67240 KB Output is correct
2 Correct 93 ms 40272 KB Output is correct
3 Correct 134 ms 62648 KB Output is correct
4 Correct 577 ms 70916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 484 ms 69880 KB Output is correct
2 Correct 933 ms 72692 KB Output is correct
3 Correct 236 ms 65108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 398 ms 68180 KB Output is correct
2 Correct 1087 ms 74364 KB Output is correct
3 Correct 1080 ms 74508 KB Output is correct
4 Correct 1107 ms 74576 KB Output is correct
5 Correct 1120 ms 74888 KB Output is correct
6 Correct 207 ms 64324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4631 ms 93276 KB Output is correct
2 Correct 907 ms 64508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5034 ms 94276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5024 ms 94992 KB Time limit exceeded
2 Halted 0 ms 0 KB -