Submission #1455720
Source Code Expand
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; inline int read(){ char ch = getchar(); int x = 0; while (ch < '0' || '9' < ch) ch = getchar(); while ('0' <= ch && ch <= '9') { x = x*10 + ch-'0'; ch = getchar(); } return x; } const int maxn = 500009; int d[maxn], pre[maxn], suf[maxn]; int n, Q, q; int main(){ n = read(); pre[0] = read(); for (int i=1; i<=n; i++) d[i] = read(); for (int i=1; i<=n; i++) if (abs(pre[i-1]-d[i]) < pre[i-1]) pre[i] = abs(pre[i-1]-d[i]); else pre[i] = pre[i-1]; suf[n+1] = 1; for (int i=n; i>=1; i--) if (d[i] >= 2*suf[i+1]) suf[i] = suf[i+1]; else suf[i] = suf[i+1] + d[i]; Q = read(); while (Q--){ q = read(); puts(pre[q-1] >= suf[q+1] ? "YES" : "NO"); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Alice in linear land |
User | Cyanic |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 786 Byte |
Status | AC |
Exec Time | 71 ms |
Memory | 7680 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-00.txt, 00-01.txt, 00-02.txt |
All | 00-00.txt, 00-01.txt, 00-02.txt, 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-00.txt | AC | 1 ms | 2176 KB |
00-01.txt | AC | 1 ms | 2176 KB |
00-02.txt | AC | 1 ms | 2176 KB |
01-00.txt | AC | 1 ms | 2176 KB |
01-01.txt | AC | 1 ms | 2176 KB |
01-02.txt | AC | 70 ms | 7680 KB |
01-03.txt | AC | 69 ms | 7680 KB |
01-04.txt | AC | 71 ms | 7680 KB |
01-05.txt | AC | 67 ms | 7680 KB |
01-06.txt | AC | 70 ms | 7680 KB |
01-07.txt | AC | 71 ms | 7680 KB |
01-08.txt | AC | 65 ms | 7424 KB |
01-09.txt | AC | 67 ms | 7424 KB |
01-10.txt | AC | 69 ms | 7424 KB |