Submission #3607227
Source Code Expand
#include <bits/stdc++.h>
#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)
using namespace std;
const int N = 1e6 + 10;
int n, a, b;
int A[N], S[N];
int buffer[N << 1], *dp;
int main() {
scanf("%d%d%d", &n, &a, &b);
n -= 2;
For(i, 1, n - 1) scanf("%d", &A[i]), S[i] = S[i - 1] + A[i];
dp = buffer + N - 5;
For(i, 0, S[n - 1]) dp[i] = i;
For(i, 1, n - 1) {
dp -= A[i];
For(j, 0, A[i] - 1) dp[j] = dp[2 * A[i] - j];
}
int q;
scanf("%d", &q);
For(T, 1, q) {
scanf("%d", &A[n]);
printf("%d%c", A[n] > S[n - 1] ? A[n] - S[n - 1] + a - b : dp[A[n]] + a - b, T == q ? '\n' : ' ');
}
return 0;
}
Submission Info
Submission Time |
|
Task |
H - Tokaido |
User |
dy0607 |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
700 Byte |
Status |
AC |
Exec Time |
71 ms |
Memory |
16512 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:16:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &n, &a, &b);
^
./Main.cpp:18:61: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
For(i, 1, n - 1) scanf("%d", &A[i]), S[i] = S[i - 1] + A[i];
^
./Main.cpp:27:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &q);
^
./Main.cpp:29:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &A[n]);
^
Judge Result
Set Name |
sample |
dataset1 |
dataset2 |
Score / Max Score |
0 / 0 |
700 / 700 |
900 / 900 |
Status |
|
|
|
Set Name |
Test Cases |
sample |
sample-01.txt, sample-02.txt |
dataset1 |
sample-01.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, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt |
dataset2 |
sample-01.txt, sample-02.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, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, sample-01.txt, sample-02.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
22 ms |
14592 KB |
01-02.txt |
AC |
2 ms |
4352 KB |
01-03.txt |
AC |
5 ms |
10496 KB |
01-04.txt |
AC |
13 ms |
10496 KB |
01-05.txt |
AC |
22 ms |
14592 KB |
01-06.txt |
AC |
22 ms |
14592 KB |
01-07.txt |
AC |
10 ms |
10496 KB |
01-08.txt |
AC |
22 ms |
14592 KB |
01-09.txt |
AC |
22 ms |
14592 KB |
01-10.txt |
AC |
5 ms |
10496 KB |
01-11.txt |
AC |
8 ms |
10496 KB |
01-12.txt |
AC |
21 ms |
14592 KB |
01-13.txt |
AC |
22 ms |
14592 KB |
01-14.txt |
AC |
21 ms |
14592 KB |
01-15.txt |
AC |
22 ms |
14592 KB |
01-16.txt |
AC |
20 ms |
14592 KB |
01-17.txt |
AC |
18 ms |
10496 KB |
01-18.txt |
AC |
18 ms |
10496 KB |
01-19.txt |
AC |
18 ms |
10496 KB |
02-01.txt |
AC |
13 ms |
10752 KB |
02-02.txt |
AC |
71 ms |
16512 KB |
02-03.txt |
AC |
69 ms |
15104 KB |
02-04.txt |
AC |
67 ms |
14976 KB |
02-05.txt |
AC |
52 ms |
11264 KB |
02-06.txt |
AC |
64 ms |
14976 KB |
02-07.txt |
AC |
65 ms |
15104 KB |
02-08.txt |
AC |
51 ms |
11776 KB |
02-09.txt |
AC |
51 ms |
11776 KB |
02-10.txt |
AC |
60 ms |
13824 KB |
02-11.txt |
AC |
69 ms |
15872 KB |
02-12.txt |
AC |
70 ms |
15872 KB |
02-13.txt |
AC |
70 ms |
15872 KB |
02-14.txt |
AC |
68 ms |
15872 KB |
02-15.txt |
AC |
61 ms |
12032 KB |
02-16.txt |
AC |
60 ms |
12032 KB |
sample-01.txt |
AC |
2 ms |
6400 KB |
sample-02.txt |
AC |
2 ms |
6400 KB |