Submission #73485878


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long

priority_queue<int,vector<int>,greater<int> > pq;
const int N = 2e5 + 5;
int a[N],b[N];

signed main()
{
	int t;
	cin >> t;
	while(t--)
	{
		while(pq.size()) pq.pop();
		int n,d;
		cin >> n >> d;
		for(int i = 1;i <= n;i++) cin >> a[i];
		for(int i = 1;i <= n;i++) cin >> b[i];
		for(int i = 1;i <= n;i++)
		{
			for(int j = 1;j <= a[i];j++) pq.push(i); 
			for(int j = 1;j <= b[i];j++) pq.pop();
			while(pq.size() && i - pq.top() + 1 > d) pq.pop();
		}
		cout << pq.size() << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task C - Omelette Restaurant
User rgr2025
Language C++23 (GCC 15.2.0)
Score 300
Code Size 598 Byte
Status AC
Exec Time 141 ms
Memory 22984 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 3684 KiB
hand_00.txt AC 61 ms 22984 KiB
hand_01.txt AC 55 ms 6784 KiB
hand_02.txt AC 47 ms 6668 KiB
hand_03.txt AC 58 ms 6564 KiB
hand_04.txt AC 59 ms 6784 KiB
hand_05.txt AC 141 ms 3468 KiB
hand_06.txt AC 49 ms 8768 KiB
hand_07.txt AC 112 ms 7060 KiB
hand_08.txt AC 1 ms 3628 KiB
random_00.txt AC 62 ms 3600 KiB
random_01.txt AC 62 ms 3612 KiB
random_02.txt AC 62 ms 3612 KiB
random_03.txt AC 62 ms 3664 KiB
random_04.txt AC 62 ms 3364 KiB
random_05.txt AC 41 ms 3492 KiB
random_06.txt AC 41 ms 3844 KiB
random_07.txt AC 41 ms 3920 KiB
random_08.txt AC 41 ms 3844 KiB
random_09.txt AC 41 ms 3940 KiB
random_10.txt AC 44 ms 6784 KiB
random_11.txt AC 44 ms 6784 KiB
random_12.txt AC 43 ms 6564 KiB
random_13.txt AC 43 ms 6740 KiB
random_14.txt AC 43 ms 6772 KiB
random_15.txt AC 43 ms 6636 KiB
random_16.txt AC 43 ms 6564 KiB
random_17.txt AC 43 ms 6564 KiB
random_18.txt AC 43 ms 6564 KiB
random_19.txt AC 44 ms 6608 KiB