Submission #73494208


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,T;
	cin>>T;
	while(T--){
		long long SP=0,R=0;
		cin>>A>>B;
		vector<int>arr(A);
		vector<int>brr(A);
		for(int i=0;i<A;i++)
		cin>>arr[i];
		for(int i=0;i<A;i++)
		cin>>brr[i];
		for(int i=0;i<A;i++){
			SP+=arr[i];
			SP-=brr[i];
			while(brr[i]>0){
//				cout<<i<<" "<<brr[i]<<" "<<arr[R]<<" "<<R<<" "<<arr[0]<<" "<<arr[1]<<endl;
//				cout<<arr[R]<<" "<<brr[i]<<endl;
				if(arr[R]>=brr[i])
				{
					arr[R]-=brr[i];
					brr[i]=0;
					if(arr[R]==0)
					R=min(R+1,1LL*(A-1));
				}
				else{
					brr[i]-=arr[R];
					arr[R]=0;
			//	cout<<brr[i]<<endl;
					R=min(R+1,1LL*(A-1));
				}
			}
			
			if(i>B-1){
				SP-=arr[i-B];
				arr[i-B]=0;
				R=max(1LL*(i-B),R);
			}
			if(i==A-1)
			cout<<SP<<endl;
		}
	}
}

Submission Info

Submission Time
Task C - Omelette Restaurant
User huhehaotedong
Language C++23 (GCC 15.2.0)
Score 300
Code Size 831 Byte
Status AC
Exec Time 141 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 3660 KiB
hand_00.txt AC 36 ms 4884 KiB
hand_01.txt AC 36 ms 4812 KiB
hand_02.txt AC 40 ms 4992 KiB
hand_03.txt AC 40 ms 4956 KiB
hand_04.txt AC 40 ms 4824 KiB
hand_05.txt AC 141 ms 3444 KiB
hand_06.txt AC 33 ms 4880 KiB
hand_07.txt AC 87 ms 4068 KiB
hand_08.txt AC 1 ms 3492 KiB
random_00.txt AC 55 ms 3604 KiB
random_01.txt AC 54 ms 3436 KiB
random_02.txt AC 55 ms 3456 KiB
random_03.txt AC 55 ms 3512 KiB
random_04.txt AC 55 ms 3488 KiB
random_05.txt AC 33 ms 3544 KiB
random_06.txt AC 32 ms 3572 KiB
random_07.txt AC 32 ms 3708 KiB
random_08.txt AC 32 ms 3732 KiB
random_09.txt AC 32 ms 3564 KiB
random_10.txt AC 34 ms 4964 KiB
random_11.txt AC 34 ms 4868 KiB
random_12.txt AC 34 ms 4752 KiB
random_13.txt AC 34 ms 4756 KiB
random_14.txt AC 34 ms 4808 KiB
random_15.txt AC 34 ms 4864 KiB
random_16.txt AC 34 ms 4940 KiB
random_17.txt AC 34 ms 4828 KiB
random_18.txt AC 34 ms 4832 KiB
random_19.txt AC 34 ms 4752 KiB