Submission #61790926
Source Code Expand
Copy
#include<bits/stdc++.h>#define int long long#define For(i, a, b) for(int i = (a); i <= (b); i++)#define Rof(i, a, b) for(int i = (a); i >= (b); i--)using namespace std;const int N = 5e5 + 5;int q, tag, tot, pos, lis[N], len[N];void Solve(){cin >> q; pos = 1;while(q--){int op, x; cin >> op;if(op == 1){cin >> x; tot++;len[tot] = x; lis[tot] = lis[tot - 1] + len[tot - 1];}else if(op == 2){tag += len[pos];pos++;}else{cin >> x;
#include<bits/stdc++.h> #define int long long #define For(i, a, b) for(int i = (a); i <= (b); i++) #define Rof(i, a, b) for(int i = (a); i >= (b); i--) using namespace std; const int N = 5e5 + 5; int q, tag, tot, pos, lis[N], len[N]; void Solve(){ cin >> q; pos = 1; while(q--){ int op, x; cin >> op; if(op == 1){ cin >> x; tot++; len[tot] = x; lis[tot] = lis[tot - 1] + len[tot - 1]; } else if(op == 2){ tag += len[pos]; pos++; } else{ cin >> x; cout << lis[pos + x - 1] - tag << '\n'; } } } signed main(){ cin.tie(0)->sync_with_stdio(0); int T = 1; //cin >> T; while(T--) Solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Snake Queue |
User | Anyees |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 663 Byte |
Status | AC |
Exec Time | 34 ms |
Memory | 8120 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
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, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 02_min_00.txt, 02_min_01.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3456 KB |
00_sample_01.txt | AC | 1 ms | 3388 KB |
00_sample_02.txt | AC | 1 ms | 3468 KB |
01_test_00.txt | AC | 1 ms | 3536 KB |
01_test_01.txt | AC | 1 ms | 3616 KB |
01_test_02.txt | AC | 1 ms | 3492 KB |
01_test_03.txt | AC | 1 ms | 3488 KB |
01_test_04.txt | AC | 1 ms | 3476 KB |
01_test_05.txt | AC | 1 ms | 3492 KB |
01_test_06.txt | AC | 31 ms | 5236 KB |
01_test_07.txt | AC | 15 ms | 4452 KB |
01_test_08.txt | AC | 31 ms | 5152 KB |
01_test_09.txt | AC | 27 ms | 4872 KB |
01_test_10.txt | AC | 31 ms | 5092 KB |
01_test_11.txt | AC | 13 ms | 4184 KB |
01_test_12.txt | AC | 31 ms | 5228 KB |
01_test_13.txt | AC | 12 ms | 4200 KB |
01_test_14.txt | AC | 31 ms | 5152 KB |
01_test_15.txt | AC | 24 ms | 4996 KB |
01_test_16.txt | AC | 23 ms | 5012 KB |
01_test_17.txt | AC | 23 ms | 5040 KB |
01_test_18.txt | AC | 26 ms | 6592 KB |
01_test_19.txt | AC | 24 ms | 6552 KB |
01_test_20.txt | AC | 24 ms | 6596 KB |
01_test_21.txt | AC | 24 ms | 6660 KB |
01_test_22.txt | AC | 31 ms | 5880 KB |
01_test_23.txt | AC | 34 ms | 5952 KB |
01_test_24.txt | AC | 27 ms | 8120 KB |
01_test_25.txt | AC | 17 ms | 8020 KB |
01_test_26.txt | AC | 25 ms | 8088 KB |
01_test_27.txt | AC | 17 ms | 5788 KB |
02_min_00.txt | AC | 1 ms | 3460 KB |
02_min_01.txt | AC | 1 ms | 3388 KB |