Submission #73487218


Source Code Expand

#if !__INCLUDE_LEVEL__
#include __FILE__

void solve() {
  int N,D;
  cin>>N>>D;
  deque<pii> que;
  vi A(N),B(N);
  //for(auto &a:A)cin>>a;
  //for(auto &b:B)cin>>b;
  rep(i,N)cin>>A[i];
  rep(i,N)cin>>B[i];
  rep(i,N){
    que.push_back({i,A[i]});
    while(!que.empty()){
      auto [d,cnt]=que.front();
      que.pop_front();
      if(B[i]<cnt){
        que.push_front({d,cnt-B[i]});
        break;
      }else B[i]-=cnt;
    }
    while(!que.empty()){
      auto [d,cnt]=que.front();
      if(i-d>=D)que.pop_front();
      else break;
    }
  }
  int sum=0;
  while(!que.empty()){
    auto [d,cnt]=que.front();
    que.pop_front();
    sum+=cnt;
  }
  cout<<sum<<el;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    fixed15;
    int T=1;
    cin>>T;
    while(T--)solve();
}

#else
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint=modint998244353;
//using mint=modint1000000007;
  
// 関数テンプレート
template<typename T> bool chmax(T &m, const T q) {
    if (m < q) {m = q; return true;} else return false; }

template<typename T> bool chmin(T &m,const T q){
    if(m>q){m=q;return true;}else return false;
}
template<typename T>
bool grid_inside(const T h, const T w, const T &m, const T &n) {
    return (m >= 0 && m < h && n >= 0 && n < w);
}
// ループマクロ
#define rep(i,r) for(int i=0;(r)>i;i++)
#define REP(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,N) for(int i=(N)-1;i>=0;i--)
#define RREP(i,r,N) for(int i=(N)-1;i>=r;i--)

// コンテナショートカット
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define pb push_back
#define fixed15 std::cout<<std::fixed << std::setprecision(15)
#define popcntll(x) __builtin_popcountll(x)
// YES/NO 出力
#define Yes cout<<"Yes"<<el
#define No cout<<"No"<<el
#define YES cout<<"YES"<<el
#define NO cout<<"NO"<<el
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

// 型エイリアス
using ll=long long;
using ull=unsigned long long;
using pqgi=priority_queue<int, vector<int>, greater<int>>;
using pqgl=priority_queue<long long, vector<long long>, greater<long long>>;
using pqgpl=priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>>;
using pqgptpl=priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>>;
using pqi=priority_queue<int>;
using pii=pair<int, int>;
using tpi=tuple<int,int,int>;
using tpl=tuple<ll,ll,ll>;
using pll=pair<long long, long long>;
using vs=vector<string>;
using vi=vector<int>;
using vb=vector<bool>;
using vl=vector<long long>;
using vc=vector<char>;
using vvi=vector<vector<int>>;
using vvl=vector<vector<long long>>;
using vvc=vector<vector<char>>;
using vvb=vector<vector<bool>>;
using vvs=vector<vector<string>>;
using vpii=vector<pii>;
using vpll=vector<pll>;
using vvpii=vector<vector<pii>>;
using vvpll=vector<vector<pll>>;
using vtiii=vector<tuple<int, int, int>>;
using lb=long double;

// 定数
const long long INF=1e18;
const int mod=1e9+7;
//const int mod=998244353;
const int MAX=1e5+10;
const int MIN=-1e9;
const vpii dir={{1,0},{-1,0},{0,1},{0,-1}};
const vpii ddir={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};
#endif


Submission Info

Submission Time
Task C - Omelette Restaurant
User yasaikeikaku
Language C++23 (GCC 15.2.0)
Score 300
Code Size 3581 Byte
Status AC
Exec Time 35 ms
Memory 6400 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 3592 KiB
hand_00.txt AC 12 ms 6400 KiB
hand_01.txt AC 12 ms 5020 KiB
hand_02.txt AC 11 ms 5060 KiB
hand_03.txt AC 12 ms 4888 KiB
hand_04.txt AC 12 ms 4912 KiB
hand_05.txt AC 35 ms 3508 KiB
hand_06.txt AC 12 ms 5432 KiB
hand_07.txt AC 24 ms 4376 KiB
hand_08.txt AC 1 ms 3528 KiB
random_00.txt AC 18 ms 3512 KiB
random_01.txt AC 18 ms 3592 KiB
random_02.txt AC 18 ms 3476 KiB
random_03.txt AC 18 ms 3624 KiB
random_04.txt AC 18 ms 3460 KiB
random_05.txt AC 12 ms 3656 KiB
random_06.txt AC 12 ms 3624 KiB
random_07.txt AC 12 ms 3656 KiB
random_08.txt AC 12 ms 3588 KiB
random_09.txt AC 12 ms 3720 KiB
random_10.txt AC 13 ms 4920 KiB
random_11.txt AC 13 ms 4876 KiB
random_12.txt AC 13 ms 4928 KiB
random_13.txt AC 13 ms 4992 KiB
random_14.txt AC 12 ms 4868 KiB
random_15.txt AC 13 ms 5020 KiB
random_16.txt AC 13 ms 4920 KiB
random_17.txt AC 13 ms 4972 KiB
random_18.txt AC 13 ms 4992 KiB
random_19.txt AC 12 ms 4920 KiB