CODE FESTIVAL 2016 Final

Submission #994103

Source codeソースコード

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int N, A[200050];
int S[200050], dp[200050], ma[200050];

int solve(int m) {
  A[N - 1] = m;
  S[0] = A[0];
  for (int i = 1; i < N; ++i) {
    S[i] = S[i - 1] + A[i];
  }
  dp[N - 1] = 0;
  ma[N - 1] = A[N - 1] - S[N - 2];
  for (int i = N - 2; i >= 1; --i) {
    dp[i] = S[i] + ma[i + 1];
    ma[i] = max(ma[i + 1], A[i] - S[i - 1] - dp[i]);
  }
  return dp[1] + A[0] - A[1];
}

int main() {
  N = in();
  for (int i = 0; i < N - 1; ++i) {
    S[i] = A[i] = in();
    if (i > 0) {
      S[i] += S[i - 1];
    }
  }
  int M = in();
  if (M > 1) {
    return 0;
  }

  printf("%d\n", solve(in()));

  return 0;
}

Submission

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

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

./Main.cpp: In function ‘int in()’:
./Main.cpp:34:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int in() { int x; scanf("%d", &x); return x; }
^
./Main.cpp: In function ‘double fin()’:
./Main.cpp:35:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
double fin() { double x; scanf("%lf", &x); return x; }
^
./Main.cpp: In function ‘Int lin()’:
./Main.cpp:36:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
Int lin() { Int x; scanf("%lld", &x); return x; }
^

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 0 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 21 ms 3328 KB
01-02.txt AC 2 ms 256 KB
01-03.txt AC 3 ms 256 KB
01-04.txt AC 11 ms 1792 KB
01-05.txt AC 21 ms 3328 KB
01-06.txt AC 21 ms 3328 KB
01-07.txt AC 8 ms 1152 KB
01-08.txt AC 21 ms 3328 KB
01-09.txt AC 21 ms 3328 KB
01-10.txt AC 2 ms 256 KB
01-11.txt AC 6 ms 896 KB
01-12.txt AC 20 ms 3200 KB
01-13.txt AC 21 ms 3328 KB
01-14.txt AC 21 ms 3328 KB
01-15.txt AC 21 ms 3328 KB
01-16.txt AC 21 ms 3328 KB
01-17.txt AC 21 ms 3328 KB
01-18.txt AC 21 ms 3328 KB
01-19.txt AC 21 ms 3328 KB
02-01.txt WA
02-02.txt WA
02-03.txt WA
02-04.txt WA
02-05.txt WA
02-06.txt WA
02-07.txt WA
02-08.txt WA
02-09.txt WA
02-10.txt WA
02-11.txt WA
02-12.txt WA
02-13.txt WA
02-14.txt WA
02-15.txt WA
02-16.txt WA
sample-01.txt AC 2 ms 256 KB
sample-02.txt WA