Submission #1004489
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }
int main() {
int N;
while(~scanf("%d", &N)) {
vector<int> A(N - 1);
for(int i = 0; i < N - 1; ++ i)
scanf("%d", &A[i]);
int sumA = accumulate(A.begin() + 2, A.end(), 0);
int S = sumA + *max_element(A.begin() + 2, A.end());
deque<int> deq;
rep(k, S)
deq.push_back(k);
reu(i, 2, N - 1) {
rep(j, A[i])
deq.push_front(deq[1 + j * 2]);
while((int)deq.size() >= S)
deq.pop_back();
}
int M;
scanf("%d", &M);
rep(i, M) {
int X;
scanf("%d", &X);
int ans = (X >= S ? X - sumA : deq[X]) + (A[0] - A[1]);
printf("%d\n", ans);
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
H - Tokaido |
User |
anta |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
1210 Byte |
Status |
AC |
Exec Time |
95 ms |
Memory |
14608 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &A[i]);
^
./Main.cpp:29:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &M);
^
./Main.cpp:32:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &X);
^
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 |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
32 ms |
5120 KB |
01-02.txt |
AC |
3 ms |
256 KB |
01-03.txt |
AC |
14 ms |
4352 KB |
01-04.txt |
AC |
23 ms |
4736 KB |
01-05.txt |
AC |
32 ms |
5120 KB |
01-06.txt |
AC |
32 ms |
5120 KB |
01-07.txt |
AC |
19 ms |
4608 KB |
01-08.txt |
AC |
32 ms |
5120 KB |
01-09.txt |
AC |
32 ms |
5120 KB |
01-10.txt |
AC |
19 ms |
7936 KB |
01-11.txt |
AC |
28 ms |
11920 KB |
01-12.txt |
AC |
40 ms |
11136 KB |
01-13.txt |
AC |
40 ms |
10368 KB |
01-14.txt |
AC |
42 ms |
11664 KB |
01-15.txt |
AC |
42 ms |
11664 KB |
01-16.txt |
AC |
42 ms |
13328 KB |
01-17.txt |
AC |
19 ms |
1024 KB |
01-18.txt |
AC |
19 ms |
1024 KB |
01-19.txt |
AC |
19 ms |
1024 KB |
02-01.txt |
AC |
23 ms |
4736 KB |
02-02.txt |
AC |
79 ms |
7040 KB |
02-03.txt |
AC |
82 ms |
5632 KB |
02-04.txt |
AC |
80 ms |
5504 KB |
02-05.txt |
AC |
67 ms |
5248 KB |
02-06.txt |
AC |
77 ms |
5504 KB |
02-07.txt |
AC |
78 ms |
5760 KB |
02-08.txt |
AC |
76 ms |
11108 KB |
02-09.txt |
AC |
66 ms |
9456 KB |
02-10.txt |
AC |
82 ms |
13328 KB |
02-11.txt |
AC |
90 ms |
12384 KB |
02-12.txt |
AC |
93 ms |
12944 KB |
02-13.txt |
AC |
95 ms |
12944 KB |
02-14.txt |
AC |
91 ms |
14608 KB |
02-15.txt |
AC |
61 ms |
2560 KB |
02-16.txt |
AC |
60 ms |
2560 KB |
sample-01.txt |
AC |
3 ms |
256 KB |
sample-02.txt |
AC |
3 ms |
256 KB |