CODE FESTIVAL 2016 Final

Submission #5398724

Source codeソースコード

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
} 
int N,M;
int A[MAXN],s;
deque<int> dp;
vector<int> v;
void Solve() {
    read(N);
    for(int i = 1 ; i < N ; ++i) {
	read(A[i]);
	if(i >= 3) s += A[i];
    }
    for(int i = 0 ; i <= s ; ++i) dp.push_back(i);
    for(int i = 3 ; i < N ; ++i) {
	v.clear();
	for(int j = 1 ; j <= A[i] ; ++j) v.pb(dp[j]);
	for(auto t : v) dp.push_front(t);
	for(int j = 1 ; j <= A[i] ; ++j) dp.pop_back();
    }
    int x;
    read(M);
    for(int i = 1 ; i <= M ; ++i) {
	read(x);
	if(x >= s) {out(x - s + A[1] - A[2]);enter;}
	else {out(dp[x] + A[1] - A[2]);enter;}
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Submission

Task問題 H - Tokaido
User nameユーザ名 sigongzi
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1600
Source lengthソースコード長 1443 Byte
File nameファイル名
Exec time実行時間 51 ms
Memory usageメモリ使用量 14460 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
dataset1 700 / 700 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 900 / 900 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 16 ms 5120 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 12 ms 4352 KB
01-04.txt AC 14 ms 4736 KB
01-05.txt AC 16 ms 5120 KB
01-06.txt AC 16 ms 5120 KB
01-07.txt AC 13 ms 4608 KB
01-08.txt AC 16 ms 5120 KB
01-09.txt AC 16 ms 5120 KB
01-10.txt AC 14 ms 7928 KB
01-11.txt AC 17 ms 11708 KB
01-12.txt AC 20 ms 10992 KB
01-13.txt AC 20 ms 10480 KB
01-14.txt AC 20 ms 11652 KB
01-15.txt AC 21 ms 12284 KB
01-16.txt AC 20 ms 13180 KB
01-17.txt AC 5 ms 1024 KB
01-18.txt AC 5 ms 1024 KB
01-19.txt AC 5 ms 1024 KB
02-01.txt AC 17 ms 4736 KB
02-02.txt AC 51 ms 7040 KB
02-03.txt AC 36 ms 5632 KB
02-04.txt AC 33 ms 5504 KB
02-05.txt AC 34 ms 5120 KB
02-06.txt AC 33 ms 5504 KB
02-07.txt AC 35 ms 5760 KB
02-08.txt AC 46 ms 12528 KB
02-09.txt AC 43 ms 9348 KB
02-10.txt AC 47 ms 13068 KB
02-11.txt AC 49 ms 12400 KB
02-12.txt AC 50 ms 12804 KB
02-13.txt AC 49 ms 13552 KB
02-14.txt AC 50 ms 14460 KB
02-15.txt AC 32 ms 2560 KB
02-16.txt AC 32 ms 2560 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB