Submission #73491201


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1145;
int n,d,a[N],b[N],qwq[N*10],dp[N],ans=0,t;
void solve()
{
	cin>>n>>d;
	ans=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	int t=0,h=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=a[i];j++) qwq[++h]=i,ans++;
		for(int j=1;j<=b[i];j++) qwq[++t]=0,ans--;
		while(1)
		{
			if(qwq[t+1]+d<=i&&t+1<=h) qwq[++t]=0,ans--;
			else break;
		}
	}
	cout<<ans<<'\n';
}
signed main()
{
	cin>>t;
	while(t--)
	{
		solve();
	}
}

Submission Info

Submission Time
Task C - Omelette Restaurant
User zhangjizhiava
Language C++23 (GCC 15.2.0)
Score 300
Code Size 532 Byte
Status AC
Exec Time 135 ms
Memory 13116 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 3440 KiB
hand_00.txt AC 40 ms 12888 KiB
hand_01.txt AC 41 ms 13116 KiB
hand_02.txt AC 44 ms 13004 KiB
hand_03.txt AC 44 ms 12912 KiB
hand_04.txt AC 44 ms 13072 KiB
hand_05.txt AC 135 ms 3588 KiB
hand_06.txt AC 35 ms 6488 KiB
hand_07.txt AC 87 ms 6520 KiB
hand_08.txt AC 1 ms 3536 KiB
random_00.txt AC 55 ms 3616 KiB
random_01.txt AC 55 ms 3600 KiB
random_02.txt AC 55 ms 3632 KiB
random_03.txt AC 55 ms 3592 KiB
random_04.txt AC 55 ms 3596 KiB
random_05.txt AC 34 ms 3844 KiB
random_06.txt AC 34 ms 3788 KiB
random_07.txt AC 33 ms 3920 KiB
random_08.txt AC 34 ms 3848 KiB
random_09.txt AC 34 ms 3652 KiB
random_10.txt AC 37 ms 9040 KiB
random_11.txt AC 37 ms 8912 KiB
random_12.txt AC 36 ms 9040 KiB
random_13.txt AC 37 ms 8744 KiB
random_14.txt AC 37 ms 8900 KiB
random_15.txt AC 37 ms 8900 KiB
random_16.txt AC 37 ms 9112 KiB
random_17.txt AC 37 ms 8896 KiB
random_18.txt AC 36 ms 8848 KiB
random_19.txt AC 37 ms 8792 KiB