Submission #73492951


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull=unsigned long long;
const int INF = 1e9;
const long long INFLL = (long long)1e18;
const double PI = acos(-1);
//cout << fixed << setprecision(15) << ans << '\n';

int main()
{
  int t;cin>>t;
  while(t--)
  {
    int n,d;cin>>n>>d;
    queue<pair<int,int>>egg;
    for(int i=1;i<=n;i++) 
    {
      int a;cin>>a;
      egg.push({i,a});
    }

    for(int i=1;i<=n;i++)
    {
      int b;cin>>b;
      while(egg.front().first<=i and b>0 and !egg.empty())
      {
        if(b<egg.front().second)
        {
          egg.front().second-=b;b=0;
        }
        else
        {
          b-=egg.front().second;
          egg.pop();
        }
      }

      while(egg.front().first+d<=i and !egg.empty())
      {
        egg.pop();
      }
    }

    int ans=0;
    while(!egg.empty())
    {
      ans+=egg.front().second;
      egg.pop();
    }

    cout<<ans<<endl;

  }
  return 0;
}

Submission Info

Submission Time
Task C - Omelette Restaurant
User maou1
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1040 Byte
Status AC
Exec Time 148 ms
Memory 4992 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 3496 KiB
hand_00.txt AC 37 ms 4908 KiB
hand_01.txt AC 37 ms 4896 KiB
hand_02.txt AC 40 ms 4956 KiB
hand_03.txt AC 41 ms 4932 KiB
hand_04.txt AC 42 ms 4908 KiB
hand_05.txt AC 148 ms 3596 KiB
hand_06.txt AC 34 ms 4920 KiB
hand_07.txt AC 91 ms 4072 KiB
hand_08.txt AC 1 ms 3572 KiB
random_00.txt AC 55 ms 3488 KiB
random_01.txt AC 56 ms 3400 KiB
random_02.txt AC 55 ms 3452 KiB
random_03.txt AC 57 ms 3400 KiB
random_04.txt AC 56 ms 3392 KiB
random_05.txt AC 34 ms 3580 KiB
random_06.txt AC 35 ms 3612 KiB
random_07.txt AC 34 ms 3756 KiB
random_08.txt AC 34 ms 3612 KiB
random_09.txt AC 34 ms 3580 KiB
random_10.txt AC 36 ms 4836 KiB
random_11.txt AC 36 ms 4856 KiB
random_12.txt AC 35 ms 4992 KiB
random_13.txt AC 35 ms 4916 KiB
random_14.txt AC 35 ms 4920 KiB
random_15.txt AC 36 ms 4856 KiB
random_16.txt AC 36 ms 4920 KiB
random_17.txt AC 37 ms 4896 KiB
random_18.txt AC 36 ms 4832 KiB
random_19.txt AC 36 ms 4856 KiB