Submission #73497264
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define int long long
void sol();
struct Eggs {
int sum, days;
};
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;cin >> t;
while(t--) sol();
return 0;
}
void sol() {
queue<Eggs> q;//有多少蛋 和他们第几天会过期
int n, d;
cin >> n >> d;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
q.push({a, i + d});
}
for (int i = 0; i < n; ++i) {
int b;
cin >> b;
while(b > 0 && !q.empty()) {
if(q.front().sum > b) {
q.front().sum -= b;
b = 0;
} else {
b -= q.front().sum;
q.pop();
}
}
while(!q.empty() && q.front().days <= i) {
q.pop();
}
}
int ans = 0;
while(!q.empty()){
ans += q.front().sum;q.pop();
}
cout << ans << '\n';
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Omelette Restaurant |
| User | cslgZ09224220 |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 1019 Byte |
| Status | AC |
| Exec Time | 30 ms |
| Memory | 6616 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 3488 KiB |
| hand_00.txt | AC | 12 ms | 6564 KiB |
| hand_01.txt | AC | 12 ms | 6564 KiB |
| hand_02.txt | AC | 11 ms | 6564 KiB |
| hand_03.txt | AC | 11 ms | 6452 KiB |
| hand_04.txt | AC | 11 ms | 6516 KiB |
| hand_05.txt | AC | 30 ms | 3568 KiB |
| hand_06.txt | AC | 11 ms | 6464 KiB |
| hand_07.txt | AC | 21 ms | 4916 KiB |
| hand_08.txt | AC | 1 ms | 3540 KiB |
| random_00.txt | AC | 15 ms | 3448 KiB |
| random_01.txt | AC | 15 ms | 3568 KiB |
| random_02.txt | AC | 15 ms | 3604 KiB |
| random_03.txt | AC | 15 ms | 3532 KiB |
| random_04.txt | AC | 16 ms | 3524 KiB |
| random_05.txt | AC | 11 ms | 3696 KiB |
| random_06.txt | AC | 12 ms | 3748 KiB |
| random_07.txt | AC | 11 ms | 3704 KiB |
| random_08.txt | AC | 11 ms | 3824 KiB |
| random_09.txt | AC | 12 ms | 3792 KiB |
| random_10.txt | AC | 13 ms | 6520 KiB |
| random_11.txt | AC | 13 ms | 6584 KiB |
| random_12.txt | AC | 13 ms | 6564 KiB |
| random_13.txt | AC | 13 ms | 6524 KiB |
| random_14.txt | AC | 13 ms | 6452 KiB |
| random_15.txt | AC | 13 ms | 6516 KiB |
| random_16.txt | AC | 13 ms | 6520 KiB |
| random_17.txt | AC | 13 ms | 6516 KiB |
| random_18.txt | AC | 13 ms | 6576 KiB |
| random_19.txt | AC | 13 ms | 6616 KiB |