Submission #73496102


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(13); } }init;
using ll = long long;
using pll = pair<ll, ll>;
const int inf = 1073741823;
const long long INF = 1LL << 60;
#define el '\n'
#define spa " "
#define pb emplace_back
#define rep(i, s, n) for(int i = (s); i < (int)(n); i++)
#define rrep(i, s, n) for(int i = (int)(n) - 1; i >= (s); i--)
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define unless(c) if(!(c))
#define until(c) while(!(c))

int sub(){
    return 0;
}

int solve() {
    ll n, d;
    cin >> n >> d;
    vector<ll> a(n);
    vector<ll> b(n);
    ll z = 0;
    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 0, n){
        cin >> b[i];
    }
    rep(i, 0, n){
        rep(j, z, n){
            a[j] -= b[i];
            b[i] = 0;
            if(a[j] == 0){
                z = j+1;
            }
            else if(a[j] < 0){
                b[i] = (-a[j]);
                z = j+1;
                a[j] = 0;
            }
            if(b[i] == 0){
                break;
            }
        }

        if(z == i-d){
            a[z] = 0;
            z++;
        }
    }

    ll ans = 0;
    rep(i, z, n){
        ans += a[i];
    }
    cout << ans << el;
    return 0;
}

int main() {
    int t = 1;
    cin >> t;
    rep(i, 0, t) {
        solve();
    }
    return 0;
}

Submission Info

Submission Time
Task C - Omelette Restaurant
User tuttutu256
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1543 Byte
Status AC
Exec Time 26 ms
Memory 6608 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 3636 KiB
hand_00.txt AC 10 ms 6516 KiB
hand_01.txt AC 10 ms 6488 KiB
hand_02.txt AC 10 ms 6516 KiB
hand_03.txt AC 10 ms 6488 KiB
hand_04.txt AC 10 ms 6564 KiB
hand_05.txt AC 26 ms 3636 KiB
hand_06.txt AC 10 ms 6516 KiB
hand_07.txt AC 19 ms 4920 KiB
hand_08.txt AC 1 ms 3684 KiB
random_00.txt AC 14 ms 3500 KiB
random_01.txt AC 14 ms 3600 KiB
random_02.txt AC 14 ms 3584 KiB
random_03.txt AC 14 ms 3684 KiB
random_04.txt AC 14 ms 3612 KiB
random_05.txt AC 10 ms 3800 KiB
random_06.txt AC 10 ms 3756 KiB
random_07.txt AC 10 ms 3840 KiB
random_08.txt AC 10 ms 3756 KiB
random_09.txt AC 10 ms 3716 KiB
random_10.txt AC 11 ms 6368 KiB
random_11.txt AC 11 ms 6516 KiB
random_12.txt AC 11 ms 6548 KiB
random_13.txt AC 11 ms 6608 KiB
random_14.txt AC 11 ms 6492 KiB
random_15.txt AC 11 ms 6488 KiB
random_16.txt AC 11 ms 6472 KiB
random_17.txt AC 11 ms 6564 KiB
random_18.txt AC 11 ms 6516 KiB
random_19.txt AC 11 ms 6488 KiB