提出 #73502009


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n, d; cin >> n >> d;
    vector<int> a(n),b(n),disc(n);
    for(int &i: a) cin >>i;
    for(int &i: b) cin >>i;
    int ceil = d, tot = 0;
    for(int i = 0; i < n; i++){
        if(i+d < n)disc[i+d] = a[i];
        tot += a[i] - b[i];
        if(ceil < n){
            disc[ceil] -= b[i];
            if(disc[ceil] <= 0){
                ceil++;
                if(ceil < n)disc[ceil] += disc[ceil-1];
            }
            if(i == ceil){
                tot -= disc[i];
                ceil++;
            }
        }
    }
    cout <<  tot << '\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    for(int _ = 0; _ < t; _++) solve();
}

提出情報

提出日時
問題 C - Omelette Restaurant
ユーザ mg00s
言語 C++ IOI-Style(GNU++20) (GCC 14.2.0)
得点 300
コード長 790 Byte
結果 AC
実行時間 27 ms
メモリ 4012 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 30
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
example_00.txt AC 0 ms 1604 KiB
hand_00.txt AC 10 ms 4012 KiB
hand_01.txt AC 10 ms 4012 KiB
hand_02.txt AC 10 ms 4012 KiB
hand_03.txt AC 11 ms 4012 KiB
hand_04.txt AC 11 ms 4012 KiB
hand_05.txt AC 27 ms 1580 KiB
hand_06.txt AC 10 ms 4012 KiB
hand_07.txt AC 19 ms 2732 KiB
hand_08.txt AC 0 ms 1580 KiB
random_00.txt AC 14 ms 1580 KiB
random_01.txt AC 14 ms 1580 KiB
random_02.txt AC 14 ms 1580 KiB
random_03.txt AC 14 ms 1580 KiB
random_04.txt AC 14 ms 1604 KiB
random_05.txt AC 9 ms 1708 KiB
random_06.txt AC 9 ms 1708 KiB
random_07.txt AC 9 ms 1708 KiB
random_08.txt AC 9 ms 1708 KiB
random_09.txt AC 9 ms 1708 KiB
random_10.txt AC 10 ms 4012 KiB
random_11.txt AC 10 ms 4012 KiB
random_12.txt AC 10 ms 3884 KiB
random_13.txt AC 10 ms 4012 KiB
random_14.txt AC 10 ms 3884 KiB
random_15.txt AC 10 ms 3884 KiB
random_16.txt AC 10 ms 4012 KiB
random_17.txt AC 10 ms 4012 KiB
random_18.txt AC 10 ms 3884 KiB
random_19.txt AC 10 ms 4012 KiB