답안 #391095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391095 2021-04-17T20:25:35 Z IloveN Pyramid Base (IOI08_pyramid_base) C++14
80 / 100
5000 ms 92652 KB
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
#define ui unsigned int
const int N=1e6+10;

struct segment_tree
{
    int t[N*2],d[N*2],n;

    void build(int p) {
      while (p > 1) p >>= 1, t[p] = min(t[p<<1], t[p<<1|1]) + d[p];
    }

    void upd(int l, int r, int value) {
      l += n - 1, r += n;
      int l0 = l, r0 = r;
      for (; l < r; l >>= 1, r >>= 1) {
        if (l&1) {
            t[l] += value;
            d[l++] += value;
        }
        if (r&1) {
            t[--r] += value;
            d[r] += value;
        }
      }
      build(l0);
      build(r0 - 1);
    }

    int get() { return t[1];}

    void init(int x)
    {
        n=x;
        memset(t,0,sizeof(t));
        memset(d,0,sizeof(d));
    }
} seg;

struct obs{int x1,x2,y1,y2,c;};
obs a[N];
int n,m,B,p;

struct event{int l,r,x;};
vector<event> vt[N];

bool check(int l)
{
    for (int i=1;i<=m;i++) vt[i].clear();
    for (int i=1;i<=p;i++)
    {
        int x1=max(a[i].x1-l+1,1);
        int y1=max(a[i].y1-l+1,1);
        int x2=min(a[i].x2,m-l+1);
        int y2=min(a[i].y2,n-l+1);
        if (x1>x2 || y1>y2) continue;
        int c=a[i].c;
        vt[x1].pb({y1,y2,c});
        vt[x2+1].pb({y1,y2,-c});
    }
    seg.init(n-l+1);
    for (int i=1;i<=m-l+1;i++)
    {
        for (event e : vt[i]) seg.upd(e.l,e.r,e.x);
        if (seg.get()<=B) return true;
    }
    return false;
}

int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>m>>n>>B>>p;
    for (int i=1;i<=p;i++) cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2>>a[i].c,a[i].c=min(a[i].c,B+1);
    int l=1,r=min(m,n),ans=0;
    while (l<=r)
    {
        int mid=(l+r)/2;
        if (check(mid)) ans=mid,l=mid+1;
        else r=mid-1;
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 39372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 39372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 39532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 39620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 39796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 39960 KB Output is correct
2 Correct 166 ms 39932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 40004 KB Output is correct
2 Correct 118 ms 39752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 40688 KB Output is correct
2 Correct 76 ms 40060 KB Output is correct
3 Correct 71 ms 40344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 43084 KB Output is correct
2 Correct 250 ms 42856 KB Output is correct
3 Correct 217 ms 43328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 313 ms 47192 KB Output is correct
2 Correct 110 ms 44392 KB Output is correct
3 Correct 123 ms 42136 KB Output is correct
4 Correct 499 ms 49392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 510 ms 50012 KB Output is correct
2 Correct 819 ms 51416 KB Output is correct
3 Correct 250 ms 47320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 420 ms 50256 KB Output is correct
2 Correct 1060 ms 53740 KB Output is correct
3 Correct 1008 ms 53356 KB Output is correct
4 Correct 1071 ms 53964 KB Output is correct
5 Correct 1064 ms 53860 KB Output is correct
6 Correct 226 ms 48228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4754 ms 80408 KB Output is correct
2 Correct 1402 ms 74548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5038 ms 87796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5052 ms 92652 KB Time limit exceeded
2 Halted 0 ms 0 KB -