답안 #782719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782719 2023-07-14T08:21:35 Z JoenPoenMan 쌀 창고 (IOI11_ricehub) C++17
17 / 100
1000 ms 1616 KB

#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

#define ALL(arr) begin(arr), end(arr)
#define CONTAINS(arr, val) (find(ALL(arr), val) == end(arr))

typedef pair<int, int> ii;

int besthub(int R, int L, int X[], long long B)
{
    vector<int> crs;
    long long cost = 0;
    int i = 0;
    int best = 0;
    int dc = 0;
    for (int x = 1; x <= L && i < R; x++)
    {
        while (crs.size() && i < R && (X[i]-x) <= crs[0]) {
            cost -= crs[0];
            crs.erase(crs.begin());
            crs.push_back(x - X[i]);
            cost += X[i]-x;
            dc -= 2;
            i++;
        }
        while (i < R && cost + (X[i]-x) <= B) {
            crs.push_back(x - X[i]);
            cost += X[i]-x;
            dc--;
            i++;
        }
        best = max(best, (int)crs.size());
        for (int &el : crs) {
            if (el == 0) {
                dc += 2;
            } 
            el++;
        }
        cost += dc;
        while (cost > B) {
            cost -= crs[0];
            crs.erase(crs.begin());
            dc--;
        }
    }
    return best;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 309 ms 312 KB Output is correct
5 Incorrect 1 ms 308 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 452 KB Output is correct
2 Correct 9 ms 468 KB Output is correct
3 Correct 10 ms 1504 KB Output is correct
4 Execution timed out 1080 ms 1616 KB Time limit exceeded
5 Halted 0 ms 0 KB -