提出 #73476630


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
typedef pair<ll,ll> PII;
typedef array<ll,2> a2;
typedef array<ll,3> a3;
int n,m,k;
int a[N],b[N];

void 打卡啦摩托(){
    deque<a2> q;
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=n;i++){
        q.push_back({a[i],i});
        int need=b[i];
        while(q.size()&&need){
            auto fr=q.front();
            q.pop_front();
            if(need>=fr[0]){
                need-=fr[0];
            }else{
                fr[0]-=need;
                need=0;
                q.push_front(fr);
                break;
            }
        }
        while(q.size()&&i-q.front()[1]>=m) q.pop_front();
    }
    ll ans=0;
    while(q.size()){
        ans+=q.front()[0];
        q.pop_front();
    }
    cout<<ans<<"\n";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _=1;
    cin>>_;
    while(_--){
        打卡啦摩托();
    }
}

提出情報

提出日時
問題 C - Omelette Restaurant
ユーザ zhishengie
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1061 Byte
結果 AC
実行時間 28 ms
メモリ 7864 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 1 ms 3528 KiB
hand_00.txt AC 12 ms 7864 KiB
hand_01.txt AC 10 ms 5264 KiB
hand_02.txt AC 10 ms 5072 KiB
hand_03.txt AC 11 ms 5080 KiB
hand_04.txt AC 11 ms 5292 KiB
hand_05.txt AC 28 ms 3724 KiB
hand_06.txt AC 11 ms 6220 KiB
hand_07.txt AC 19 ms 5164 KiB
hand_08.txt AC 1 ms 3640 KiB
random_00.txt AC 15 ms 3756 KiB
random_01.txt AC 15 ms 3536 KiB
random_02.txt AC 14 ms 3756 KiB
random_03.txt AC 15 ms 3628 KiB
random_04.txt AC 14 ms 3724 KiB
random_05.txt AC 10 ms 3744 KiB
random_06.txt AC 10 ms 3720 KiB
random_07.txt AC 10 ms 3720 KiB
random_08.txt AC 10 ms 3628 KiB
random_09.txt AC 10 ms 3744 KiB
random_10.txt AC 11 ms 5256 KiB
random_11.txt AC 11 ms 5292 KiB
random_12.txt AC 11 ms 5292 KiB
random_13.txt AC 11 ms 5264 KiB
random_14.txt AC 11 ms 5144 KiB
random_15.txt AC 11 ms 5072 KiB
random_16.txt AC 11 ms 5080 KiB
random_17.txt AC 11 ms 5080 KiB
random_18.txt AC 11 ms 5300 KiB
random_19.txt AC 11 ms 5292 KiB