Submission #73503458


Source Code Expand

#include<cstring> 
#include<iostream>
#include<algorithm>
using namespace std;

int a[200005],b[200005],q[200005];

void solve(){
	int n,d;
	int l=0,r=0,pl=0;
    scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++){
		r++;
		q[r]=a[i];
		pl=max(l+1,pl);
		while(b[i]&&pl<=r){
			if(q[pl]==0) pl++;
			else {
				int c=min(q[pl],b[i]);
				q[pl]-=c;
				b[i]-=c;
			}
		}
		if(i>d){
			l++;
		}
	}
	long long ans=0;
	for(int i=l+1;i<=r;i++){
		ans+=q[i];
	}
	printf("%lld\n",ans);
	
	return ;
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		solve();
	}
	
	return 0;
} 

Submission Info

Submission Time
Task C - Omelette Restaurant
User zgmbsydmz
Language C++23 (GCC 15.2.0)
Score 300
Code Size 712 Byte
Status AC
Exec Time 32 ms
Memory 6308 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 3824 KiB
hand_00.txt AC 15 ms 6160 KiB
hand_01.txt AC 15 ms 6216 KiB
hand_02.txt AC 16 ms 6200 KiB
hand_03.txt AC 16 ms 6140 KiB
hand_04.txt AC 15 ms 6200 KiB
hand_05.txt AC 32 ms 3768 KiB
hand_06.txt AC 15 ms 6136 KiB
hand_07.txt AC 24 ms 4860 KiB
hand_08.txt AC 1 ms 3700 KiB
random_00.txt AC 20 ms 3720 KiB
random_01.txt AC 20 ms 3656 KiB
random_02.txt AC 20 ms 3708 KiB
random_03.txt AC 20 ms 3740 KiB
random_04.txt AC 20 ms 3656 KiB
random_05.txt AC 15 ms 3784 KiB
random_06.txt AC 15 ms 3828 KiB
random_07.txt AC 15 ms 3896 KiB
random_08.txt AC 15 ms 4004 KiB
random_09.txt AC 15 ms 3832 KiB
random_10.txt AC 17 ms 6256 KiB
random_11.txt AC 17 ms 6136 KiB
random_12.txt AC 17 ms 6008 KiB
random_13.txt AC 16 ms 6308 KiB
random_14.txt AC 17 ms 6012 KiB
random_15.txt AC 16 ms 6088 KiB
random_16.txt AC 17 ms 6172 KiB
random_17.txt AC 16 ms 6200 KiB
random_18.txt AC 17 ms 6132 KiB
random_19.txt AC 17 ms 6172 KiB