Please sign in first.
Submission #73485796
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using P=pair<ll,ll>;
using T=tuple<ll,ll,ll>;
#include <atcoder/all>
using namespace atcoder;
// using mint=modint998244353;
// using mint=modint1000000007;
// int op(int a,int b){return (a+b);}
// int e(){return 0;}
int cnt(deque<P> q){
int ret=0;
while(!q.empty()){
auto [c,j]=q.front();
q.pop_front();
ret+=c;
}
return ret;
}
int main() {
int t;cin>>t;
while(t--){
int n,d;cin>>n>>d;
deque<P> q;
vector<int> a(n),b(n);
rep(i,n)cin>>a[i];
rep(i,n)cin>>b[i];
rep(i,n){
q.push_back({a[i],i});
while(!q.empty()){
auto [c,j]=q.front();
q.pop_front();
if(c>b[i]){
c-=b[i];
q.push_front({c,j});
break;
}
else{
b[i]-=c;
}
}
if(!q.empty()){
auto [c,j]=q.front();
if(j+d==i)q.pop_front();
}
// cout<<cnt(q)<<endl;
}
int ans=cnt(q);
cout<<ans<<endl;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Omelette Restaurant |
| User | Shota_Otsuka |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 1208 Byte |
| Status | AC |
| Exec Time | 159 ms |
| Memory | 10712 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 3640 KiB |
| hand_00.txt | AC | 40 ms | 10712 KiB |
| hand_01.txt | AC | 39 ms | 4808 KiB |
| hand_02.txt | AC | 42 ms | 4824 KiB |
| hand_03.txt | AC | 42 ms | 4932 KiB |
| hand_04.txt | AC | 43 ms | 4752 KiB |
| hand_05.txt | AC | 159 ms | 3492 KiB |
| hand_06.txt | AC | 36 ms | 6348 KiB |
| hand_07.txt | AC | 98 ms | 5468 KiB |
| hand_08.txt | AC | 1 ms | 3476 KiB |
| random_00.txt | AC | 59 ms | 3588 KiB |
| random_01.txt | AC | 59 ms | 3580 KiB |
| random_02.txt | AC | 59 ms | 3432 KiB |
| random_03.txt | AC | 59 ms | 3580 KiB |
| random_04.txt | AC | 59 ms | 3608 KiB |
| random_05.txt | AC | 35 ms | 3736 KiB |
| random_06.txt | AC | 35 ms | 3552 KiB |
| random_07.txt | AC | 34 ms | 3736 KiB |
| random_08.txt | AC | 35 ms | 3768 KiB |
| random_09.txt | AC | 43 ms | 3700 KiB |
| random_10.txt | AC | 36 ms | 4940 KiB |
| random_11.txt | AC | 37 ms | 4952 KiB |
| random_12.txt | AC | 36 ms | 4812 KiB |
| random_13.txt | AC | 36 ms | 4732 KiB |
| random_14.txt | AC | 36 ms | 4824 KiB |
| random_15.txt | AC | 36 ms | 4692 KiB |
| random_16.txt | AC | 36 ms | 4808 KiB |
| random_17.txt | AC | 36 ms | 4812 KiB |
| random_18.txt | AC | 36 ms | 4780 KiB |
| random_19.txt | AC | 37 ms | 4696 KiB |