CODE FESTIVAL 2016 Final

Submission #5855964

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;

const int MN = 200010;

int N, M;
int A[MN], X[MN], psum[MN];

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        scanf("%d", &A[i]);
    }

    scanf("%d", &M);

    for(int i = 0; i < M; i++) {
        scanf("%d", &X[i]);
    }

    for(int i = 0; i < N - 1; i++) {
        psum[i] = A[i];
        if(i) psum[i] += psum[i - 1];
    }

    if(N == 3) {
        for(int i = 0; i < M; i++) {
            printf("%d\n", X[i] + A[0] - A[1]);
        }
        return 0;
    }

    deque<int> dq;
    for(int i = 0; i >= -psum[1]; i--) dq.push_front(i);

    for(int i = 3; i < N - 1; i++) {
        vector<int> add;
        int q = 1;
        for(int j = -psum[i - 2] - 1; j >= -psum[i - 1]; j--) {
            if(dq.size() <= q) add.push_back(q + 1 - (int)dq.size());
            else add.push_back(dq[q]);
            q++;
        }
        for(int j = 0; j < add.size(); j++) dq.push_front(add[j]);
    }

    for(int i = 0; i < M; i++) {
        int t = X[i] - psum[N - 2];
        if(t < -psum[N - 3]) t = -2 * psum[N - 3] - t;
        t += psum[N - 3];

        printf("%d\n", (t < dq.size()? dq[t] : t + 1 - (int)dq.size()) + psum[1] + A[0] - A[1]);
    }
}

Submission

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

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
./Main.cpp:13:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &A[i]);
^
./Main.cpp:16:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &M);
^
./Main.cpp:19:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &X[i]);
^

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 55 ms 5888 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 13 ms 4736 KB
01-04.txt AC 38 ms 5120 KB
01-05.txt AC 55 ms 5888 KB
01-06.txt AC 55 ms 5888 KB
01-07.txt AC 30 ms 4736 KB
01-08.txt AC 53 ms 5888 KB
01-09.txt AC 53 ms 5888 KB
01-10.txt AC 12 ms 6004 KB
01-11.txt AC 16 ms 7920 KB
01-12.txt AC 35 ms 8660 KB
01-13.txt AC 36 ms 7356 KB
01-14.txt AC 36 ms 9068 KB
01-15.txt AC 36 ms 9324 KB
01-16.txt AC 27 ms 9840 KB
01-17.txt AC 23 ms 5888 KB
01-18.txt AC 23 ms 5888 KB
01-19.txt AC 22 ms 5888 KB
02-01.txt AC 29 ms 4992 KB
02-02.txt AC 98 ms 8576 KB
02-03.txt AC 97 ms 9088 KB
02-04.txt AC 99 ms 7040 KB
02-05.txt AC 53 ms 6016 KB
02-06.txt AC 92 ms 7040 KB
02-07.txt AC 94 ms 7296 KB
02-08.txt AC 55 ms 8008 KB
02-09.txt AC 54 ms 8500 KB
02-10.txt AC 66 ms 9324 KB
02-11.txt AC 78 ms 9324 KB
02-12.txt AC 77 ms 9456 KB
02-13.txt AC 78 ms 9328 KB
02-14.txt AC 68 ms 10608 KB
02-15.txt AC 65 ms 8192 KB
02-16.txt AC 65 ms 8192 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB