Submission #73788592


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)

// ======================================== //

int solve()
{
    int N, D;
    cin >> N >> D;
    vector<int> A(N), B(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];

    queue<int> que;
    rep(i, 0, N)
    {
        rep(j, 0, A[i]) que.push(i);
        rep(j, 0, B[i]) que.pop();
        while (!que.empty() && que.front() <= i - D)
            que.pop();
    }

    return que.size();
}

int main()
{
    int T;
    cin >> T;

    while (T--)
    {
        cout << solve() << endl;
    }

    return 0;
}

Submission Info

Submission Time
Task C - Omelette Restaurant
User Yuulis
Language C++23 (GCC 15.2.0)
Score 300
Code Size 680 Byte
Status AC
Exec Time 159 ms
Memory 12172 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 30
Set Name Test Cases
Sample example_00.txt
All example_00.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3616 KiB
hand_00.txt AC 43 ms 12172 KiB
hand_01.txt AC 41 ms 4888 KiB
hand_02.txt AC 44 ms 4764 KiB
hand_03.txt AC 45 ms 4892 KiB
hand_04.txt AC 45 ms 4788 KiB
hand_05.txt AC 159 ms 3484 KiB
hand_06.txt AC 36 ms 5504 KiB
hand_07.txt AC 99 ms 5004 KiB
hand_08.txt AC 1 ms 3484 KiB
random_00.txt AC 62 ms 3428 KiB
random_01.txt AC 63 ms 3564 KiB
random_02.txt AC 62 ms 3556 KiB
random_03.txt AC 62 ms 3492 KiB
random_04.txt AC 62 ms 3364 KiB
random_05.txt AC 38 ms 3540 KiB
random_06.txt AC 38 ms 3712 KiB
random_07.txt AC 38 ms 3620 KiB
random_08.txt AC 38 ms 3668 KiB
random_09.txt AC 38 ms 3612 KiB
random_10.txt AC 40 ms 4684 KiB
random_11.txt AC 40 ms 4812 KiB
random_12.txt AC 39 ms 4832 KiB
random_13.txt AC 39 ms 4748 KiB
random_14.txt AC 39 ms 4800 KiB
random_15.txt AC 39 ms 4900 KiB
random_16.txt AC 40 ms 4804 KiB
random_17.txt AC 40 ms 4752 KiB
random_18.txt AC 39 ms 4868 KiB
random_19.txt AC 40 ms 4736 KiB