提出 #67314791
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
class Q {
struct item { long long v, c; item* ptr; };
item *f, *r;
public:
Q(): f(nullptr), r(nullptr) {}
void ins(long long cc, long long vv) {
item* t = new item{vv, cc, nullptr};
if (!f && !r) f = r = t;
else { r->ptr = t; r = t; }
}
long long ext(long long k) {
long long s = 0;
while (k) {
item* t = f;
long long d = min(k, t->c);
s += d * t->v;
k -= d;
t->c -= d;
if (!t->c) {
f = f->ptr;
if (!f) r = nullptr;
delete t;
}
}
return s;
}
};
int main(){
int Qn;
cin >> Qn;
Q q;
while (Qn--) {
int t; cin >> t;
if (t == 1) {
long long c, x; cin >> c >> x;
q.ins(c, x);
} else {
long long k; cin >> k;
cout << q.ext(k) << "\n";
}
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Large Queue |
| ユーザ | Naman____17 |
| 言語 | C++ 17 (Clang 16.0.6) |
| 得点 | 300 |
| コード長 | 1061 Byte |
| 結果 | AC |
| 実行時間 | 201 ms |
| メモリ | 9728 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3656 KiB |
| 00_sample_01.txt | AC | 1 ms | 3508 KiB |
| 00_sample_02.txt | AC | 1 ms | 3480 KiB |
| 01_test_00.txt | AC | 2 ms | 3464 KiB |
| 01_test_01.txt | AC | 2 ms | 3516 KiB |
| 01_test_02.txt | AC | 2 ms | 3452 KiB |
| 01_test_03.txt | AC | 1 ms | 3516 KiB |
| 01_test_04.txt | AC | 126 ms | 3512 KiB |
| 01_test_05.txt | AC | 102 ms | 3596 KiB |
| 01_test_06.txt | AC | 152 ms | 3612 KiB |
| 01_test_07.txt | AC | 22 ms | 3416 KiB |
| 01_test_08.txt | AC | 125 ms | 3528 KiB |
| 01_test_09.txt | AC | 19 ms | 3660 KiB |
| 01_test_10.txt | AC | 166 ms | 4608 KiB |
| 01_test_11.txt | AC | 181 ms | 3520 KiB |
| 01_test_12.txt | AC | 189 ms | 4880 KiB |
| 01_test_13.txt | AC | 201 ms | 6624 KiB |
| 01_test_14.txt | AC | 200 ms | 6628 KiB |
| 01_test_15.txt | AC | 201 ms | 6600 KiB |
| 01_test_16.txt | AC | 118 ms | 9728 KiB |
| 01_test_17.txt | AC | 122 ms | 9680 KiB |
| 01_test_18.txt | AC | 1 ms | 3580 KiB |
| 01_test_19.txt | AC | 188 ms | 6676 KiB |