답안 #993699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993699 2024-06-06T10:15:20 Z codefox Pyramid Base (IOI08_pyramid_base) C++14
70 / 100
5000 ms 101400 KB
#include<bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define arr array<int, 5>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

int N = 1<<20;

vector<int> bmin(2*N, 0);
vector<int> badd(2*N, 0);

void update(int curr, int l, int r, int a, int b, int add, int dd)
{
    if (r<=a || l>=b) 
    {
        bmin[curr] += add;
        badd[curr] += add;
        return;
    }
    if (a<=l && r<=b)
    {
        add+=dd;
        bmin[curr] += add;
        badd[curr] += add;
        return;
    }
    int m = (l+r)/2;
    add+=badd[curr];
    badd[curr] = 0;
    update(curr*2, l, m, a, b, add, dd);
    update(curr*2+1, m, r, a, b, add, dd);
    bmin[curr] = min(bmin[curr*2], bmin[curr*2+1]);
}

int finde(int pos)
{
    int curr = 1;
    int sol = 2*1e9+1;
    int add = 0;
    for (int i = 19; i >= 0; i--)
    {
        add += badd[curr];
        curr*=2;
        if (pos < (1<<i)) continue;
        pos -= 1<<i;
        sol = min(sol, bmin[curr]+add);
        curr++;
    }
    return sol;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x, y;
    cin >> x >> y;
    int b, n;
    cin >> b >> n;

    vector<arr> ele(n);
    for (int i= 0; i < n; i++)
    {
        int x1, y1, x2, y2, c;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        x1--; y1--; x2--; y2--;
        ele[i] = {x1, y1, x2, y2, c};
    }

    int sum = 0;
    for (int i = 19; i >= 0; i--)
    {
        sum += 1<<i;
        vector<vector<arr>> begin(1e6);
        vector<vector<arr>> ende(1e6);
        bmin.assign(2*N, 0);
        badd.assign(2*N, 0);
        for (int j = 0; j < n; j++)
        {
            begin[max(0, ele[j][0]-sum+1)].push_back({max(0, ele[j][1]-sum+1), ele[j][3], ele[j][4]});
            ende[ele[j][2]].push_back({max(0, ele[j][1]-sum+1), ele[j][3], ele[j][4]});
        }
        int mn = 2*1e9+1;
        int u = 0;
        for (int j = 0; j < x-sum+1; j++)
        {
            for (arr ele2:begin[j])  update(1, 0, N, ele2[0], ele2[1]+1, 0, ele2[2]);
            if (u || mn == 2*1e9+1) 
            {
                mn = min(mn, finde(y-sum+1));
                u=0; 
            }
            if (mn <= b) break;
            for (arr ele2:ende[j]) 
            {
                u=1;
                update(1, 0, N, ele2[0], ele2[1]+1, 0, -ele2[2]);
            }
        }
        if (mn > b) sum -= 1<<i;
    }
    cout << sum;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 232 ms 63896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 63828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 200 ms 63916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 64004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 218 ms 64004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 64036 KB Output is correct
2 Correct 272 ms 63824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 64036 KB Output is correct
2 Correct 258 ms 64032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 419 ms 64500 KB Output is correct
2 Correct 316 ms 64540 KB Output is correct
3 Correct 227 ms 64488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 65384 KB Output is correct
2 Correct 521 ms 65336 KB Output is correct
3 Correct 473 ms 65272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 535 ms 66124 KB Output is correct
2 Correct 880 ms 66060 KB Output is correct
3 Correct 245 ms 65940 KB Output is correct
4 Correct 695 ms 66140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 884 ms 66372 KB Output is correct
2 Correct 1189 ms 66460 KB Output is correct
3 Correct 813 ms 66872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1016 ms 67408 KB Output is correct
2 Correct 1419 ms 67304 KB Output is correct
3 Correct 1318 ms 67108 KB Output is correct
4 Correct 1358 ms 67128 KB Output is correct
5 Correct 1361 ms 67368 KB Output is correct
6 Correct 836 ms 67688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5099 ms 82996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5019 ms 92440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5084 ms 101400 KB Time limit exceeded
2 Halted 0 ms 0 KB -