Submission #1605749
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int MAX = (1e5)+1; int X, n, q; long long r[MAX], t[MAX], a[MAX]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> X >> n; for(int i = 1; i <= n; i++) cin >> r[i]; cin >> q; long long mn = 0, mx = X, sum = 0; for(int i = 1, j = 1, mul = -1; i <= q; i++) { cin >> t[i] >> a[i]; while(j <= n && r[j] <= t[i]) { sum += mul * (r[j] - r[j-1]); mn += mul * (r[j] - r[j-1]); mx += mul * (r[j] - r[j-1]); mn = max(0ll, mn); mn = min(1ll * X, mn); mx = max(0ll, mx); mx = min(1ll * X, mx); mul *= -1; ++j; } a[i] += sum; if(a[i] < mn) a[i] = mn; if(a[i] > mx) a[i] = mx; a[i] += mul * (t[i] - r[j-1]); // always over 1 a[i] = max(0ll, a[i]); a[i] = min(1ll * X, a[i]); cout << a[i] << '\n'; } }
Submission Info
Submission Time | |
---|---|
Task | F - Sandglass |
User | zawini54 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 847 Byte |
Status | AC |
Exec Time | 40 ms |
Memory | 3584 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt, 1_040.txt, 1_041.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | AC | 31 ms | 2816 KB |
1_004.txt | AC | 33 ms | 2816 KB |
1_005.txt | AC | 35 ms | 2816 KB |
1_006.txt | AC | 30 ms | 2816 KB |
1_007.txt | AC | 33 ms | 2816 KB |
1_008.txt | AC | 34 ms | 2816 KB |
1_009.txt | AC | 31 ms | 2944 KB |
1_010.txt | AC | 33 ms | 2944 KB |
1_011.txt | AC | 35 ms | 2944 KB |
1_012.txt | AC | 32 ms | 2944 KB |
1_013.txt | AC | 34 ms | 2944 KB |
1_014.txt | AC | 36 ms | 2944 KB |
1_015.txt | AC | 32 ms | 3072 KB |
1_016.txt | AC | 34 ms | 3072 KB |
1_017.txt | AC | 37 ms | 3072 KB |
1_018.txt | AC | 33 ms | 3200 KB |
1_019.txt | AC | 35 ms | 3200 KB |
1_020.txt | AC | 37 ms | 3200 KB |
1_021.txt | AC | 34 ms | 3072 KB |
1_022.txt | AC | 36 ms | 3328 KB |
1_023.txt | AC | 38 ms | 3328 KB |
1_024.txt | AC | 34 ms | 3072 KB |
1_025.txt | AC | 37 ms | 3328 KB |
1_026.txt | AC | 38 ms | 3328 KB |
1_027.txt | AC | 36 ms | 3200 KB |
1_028.txt | AC | 37 ms | 3200 KB |
1_029.txt | AC | 39 ms | 3456 KB |
1_030.txt | AC | 37 ms | 3200 KB |
1_031.txt | AC | 37 ms | 3200 KB |
1_032.txt | AC | 40 ms | 3584 KB |
1_033.txt | AC | 27 ms | 2688 KB |
1_034.txt | AC | 27 ms | 2560 KB |
1_035.txt | AC | 37 ms | 3328 KB |
1_036.txt | AC | 29 ms | 2688 KB |
1_037.txt | AC | 28 ms | 2688 KB |
1_038.txt | AC | 39 ms | 3456 KB |
1_039.txt | AC | 29 ms | 2432 KB |
1_040.txt | AC | 29 ms | 2816 KB |
1_041.txt | AC | 40 ms | 3584 KB |