답안 #430361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
430361 2021-06-16T13:09:31 Z arayi Pyramid Base (IOI08_pyramid_base) C++17
70 / 100
5000 ms 145680 KB
//Arayi
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>   
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>
 
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;
 
const int N = 2e6 + 30;
 
 
int n, k, m, p;
int x1[N], x2[N], y1[N], y2[N], c[N];
vector <pair<pair<int, int>, int> > fp[N];
lli t[4*N], flg[4*N];
void push(int nd)
{
    t[nd] += flg[nd];
    flg[nd*2] += flg[nd];
    flg[nd*2+1] += flg[nd];
    flg[nd] = 0;
}
void upd(int l, int r, int v, int nl = 1, int nr = m, int nd = 1)
{
    push(nd);
    if(l > nr || r < nl) return;
    if(l == nl && nr == r)
    {
        flg[nd] += v;
        push(nd);
        return;
    }
    int mid = (nl + nr) / 2;
    upd(l, min(mid, r), v, nl, mid, nd*2);
    upd(max(mid + 1, l), r, v, mid + 1, nr, nd * 2 + 1);
    t[nd] = min(t[nd*2], t[nd*2+1]);
}
bool stg(int md)
{
    for (int i = 0; i <= 4*m; i++) flg[i]=t[i]=0;
    upd(m - md + 2, m, k + 1);
    for (int i = 1; i <= n - md + 1; i++)
    {
        for(auto& p : fp[i])
            upd(p.fr.fr, p.fr.sc, p.sc);
        push(1);
        if(t[1] <= k) return 1;
    }
    return 0;
}
int main()
{
    fastio;
    //freopen("input.in", "r", stdin);
    cin >> n >> m >> k >> p;
    for (int i = 0; i < p; i++) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i] >> c[i];
    int l = 1, r = min(n, m), ans = 0;
    while(l <= r)
    {
        int md = (l + r) / 2;
        for (int i = 0; i < p; i++)
        {
            fp[max(1, x1[i] - md + 1)].ad(MP(MP(max(1, y1[i] - md + 1), y2[i]), c[i]));
            fp[x2[i] + 1].ad(MP(MP(max(1, y1[i] - md + 1), y2[i]), -c[i]));
        }
        if(stg(md)) ans = md, l=md+1;
        else r=md-1;
        for (int i = 0; i <= n + 1; i++) fp[i].clear();
    }
    cout << ans << endl;
    return 0;
}
 
/*
    __
  *(><)*
    \/ /
    ||/
  --||
    ||
    /\
   /  \
  /    \
 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 47308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 47228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 47344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 48240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 54808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 321 ms 110440 KB Output is correct
2 Correct 437 ms 111036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 449 ms 110648 KB Output is correct
2 Correct 328 ms 110276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 48452 KB Output is correct
2 Correct 108 ms 48708 KB Output is correct
3 Correct 91 ms 48720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 57192 KB Output is correct
2 Correct 576 ms 57692 KB Output is correct
3 Correct 536 ms 57728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 983 ms 116476 KB Output is correct
2 Correct 144 ms 52164 KB Output is correct
3 Correct 424 ms 112696 KB Output is correct
4 Correct 1368 ms 120336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1649 ms 119192 KB Output is correct
2 Correct 2250 ms 122212 KB Output is correct
3 Correct 1084 ms 114372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1629 ms 117392 KB Output is correct
2 Correct 2955 ms 124416 KB Output is correct
3 Correct 2769 ms 124936 KB Output is correct
4 Correct 2891 ms 125340 KB Output is correct
5 Correct 2945 ms 125368 KB Output is correct
6 Correct 1144 ms 114720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5106 ms 138960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5081 ms 142192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5054 ms 145680 KB Time limit exceeded
2 Halted 0 ms 0 KB -