Submission #994070


Source Code Expand

#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 A[100050];
int S[100050], dp[100050], ma[100050];

int main() {
  int 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;
  }

  A[N - 1] = in();
  S[N - 1] = A[N - 1] + S[N - 2];
  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]);
  }

  printf("%d\n", dp[1] + A[0] - A[1]);

  return 0;
}

Submission Info

Submission Time
Task H - Tokaido
User japlj
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1516 Byte
Status WA
Exec Time 266 ms
Memory 1664 KB

Compile Error

./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; }
                                     ^

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 0 / 700 0 / 900
Status
AC × 1
WA × 1
AC × 7
RE × 13
AC × 7
WA × 6
RE × 24
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 RE 266 ms 1024 KB
01-02.txt AC 3 ms 256 KB
01-03.txt AC 3 ms 256 KB
01-04.txt AC 12 ms 1664 KB
01-05.txt RE 119 ms 1024 KB
01-06.txt RE 119 ms 1024 KB
01-07.txt AC 8 ms 1152 KB
01-08.txt RE 119 ms 1024 KB
01-09.txt RE 119 ms 1024 KB
01-10.txt AC 3 ms 256 KB
01-11.txt AC 6 ms 896 KB
01-12.txt RE 119 ms 1024 KB
01-13.txt RE 120 ms 1024 KB
01-14.txt RE 120 ms 1024 KB
01-15.txt RE 121 ms 1024 KB
01-16.txt RE 120 ms 1024 KB
01-17.txt RE 122 ms 1024 KB
01-18.txt RE 122 ms 1024 KB
01-19.txt RE 121 ms 1024 KB
02-01.txt WA 5 ms 512 KB
02-02.txt RE 119 ms 1024 KB
02-03.txt RE 120 ms 1024 KB
02-04.txt RE 123 ms 1024 KB
02-05.txt WA 3 ms 256 KB
02-06.txt RE 120 ms 1024 KB
02-07.txt RE 121 ms 1024 KB
02-08.txt WA 2 ms 256 KB
02-09.txt WA 3 ms 256 KB
02-10.txt WA 11 ms 1024 KB
02-11.txt RE 120 ms 1024 KB
02-12.txt RE 122 ms 1024 KB
02-13.txt RE 121 ms 1024 KB
02-14.txt RE 120 ms 1024 KB
02-15.txt RE 121 ms 1024 KB
02-16.txt RE 120 ms 1024 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt WA 2 ms 256 KB