Submission #73492470
Source Code Expand
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <atcoder/all>
#define DEBUG_PRINT(x) std::cerr << #x << ": " << (x) << std::endl
#define SQUARED(x) ((x) * (x))
#define CUBED(x) ((x) * (x) * (x))
#define CEIL(x, y) ((x + y - 1) / y)
#define FLOOR(x, y) (x / y)
#define CTOI(c) ((c) - '0')
#define CHECK_HW(h, w) (0 <= h and h < H and 0 <= w and w < W)
using namespace std;
using namespace atcoder;
const long long INF = 1e15;
const long double EPS = 1e-8;
int main()
{
long long T;
cin >> T;
for (int ttt = 0; ttt < T; ttt++) {
long long N, D;
vector<long long> A, B;
cin >> N >> D;
for (int i = 0; i < N; i++) {
long long a;
cin >> a;
A.push_back(a);
}
for (int i = 0; i < N; i++) {
long long b;
cin >> b;
B.push_back(b);
}
deque<pair<long long, long long>> egg;
for (int i = 0; i < N; i++) {
egg.push_back({i, A[i]});
while (true) {
auto&& [d, n] = egg.front();
if (B[i] > n) {
B[i] -= n;
egg.pop_front();
}
else {
n -= B[i];
break;
}
}
while (!egg.empty()) {
auto&& [d, n] = egg.front();
if (i - d >= D) {
egg.pop_front();
}
else {
break;
}
}
}
long long ans = 0;
while (!egg.empty()) {
auto [d, n] = egg.front();
ans += n;
egg.pop_front();
}
cout << ans << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Omelette Restaurant |
| User | hajime0316 |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 1489 Byte |
| Status | AC |
| Exec Time | 158 ms |
| Memory | 9320 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 | 3596 KiB |
| hand_00.txt | AC | 43 ms | 9320 KiB |
| hand_01.txt | AC | 42 ms | 7972 KiB |
| hand_02.txt | AC | 46 ms | 7976 KiB |
| hand_03.txt | AC | 46 ms | 7976 KiB |
| hand_04.txt | AC | 57 ms | 7848 KiB |
| hand_05.txt | AC | 158 ms | 3416 KiB |
| hand_06.txt | AC | 39 ms | 7912 KiB |
| hand_07.txt | AC | 98 ms | 5672 KiB |
| hand_08.txt | AC | 1 ms | 3456 KiB |
| random_00.txt | AC | 63 ms | 3544 KiB |
| random_01.txt | AC | 63 ms | 3404 KiB |
| random_02.txt | AC | 64 ms | 3480 KiB |
| random_03.txt | AC | 64 ms | 3480 KiB |
| random_04.txt | AC | 63 ms | 3620 KiB |
| random_05.txt | AC | 37 ms | 3668 KiB |
| random_06.txt | AC | 37 ms | 3980 KiB |
| random_07.txt | AC | 36 ms | 3664 KiB |
| random_08.txt | AC | 37 ms | 3716 KiB |
| random_09.txt | AC | 36 ms | 3852 KiB |
| random_10.txt | AC | 40 ms | 7848 KiB |
| random_11.txt | AC | 39 ms | 7976 KiB |
| random_12.txt | AC | 39 ms | 7976 KiB |
| random_13.txt | AC | 39 ms | 7976 KiB |
| random_14.txt | AC | 39 ms | 7880 KiB |
| random_15.txt | AC | 39 ms | 7956 KiB |
| random_16.txt | AC | 39 ms | 7956 KiB |
| random_17.txt | AC | 39 ms | 7920 KiB |
| random_18.txt | AC | 39 ms | 7980 KiB |
| random_19.txt | AC | 39 ms | 7840 KiB |