CODE FESTIVAL 2016 Final (Parallel)

Submission #1337578

Source codeソースコード

#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
int a[N];
int64 s[N], dp[N];

int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &m);
  assert(m == 1);
  scanf("%d", &a[n - 1]);
  s[0] = a[0];
  for (int i = 1; i < n; ++i) {
    s[i] = s[i - 1] + a[i];
  }
  dp[n - 1] = 0;
  int64 best = s[n - 2] - a[n - 1] + dp[n - 1];
  for (int i = n - 2; i >= 1; --i) {
    dp[i] = s[i] - best;
    best = min(best, s[i - 1] - a[i] + dp[i]);
  }
  printf("%lld\n", dp[1] + a[0] - a[1]);
  return 0;
}

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:47:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:49:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
./Main.cpp:51:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &m);
^
./Main.cpp:53:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[n - 1]);
^

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,sample-01.txt,sample-02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 17 ms 4096 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 1 ms 256 KB
01-04.txt AC 9 ms 2048 KB
01-05.txt AC 17 ms 4096 KB
01-06.txt AC 17 ms 4096 KB
01-07.txt AC 6 ms 1408 KB
01-08.txt AC 18 ms 4096 KB
01-09.txt AC 18 ms 4096 KB
01-10.txt AC 1 ms 256 KB
01-11.txt AC 4 ms 1024 KB
01-12.txt AC 17 ms 3968 KB
01-13.txt AC 18 ms 4096 KB
01-14.txt AC 18 ms 4096 KB
01-15.txt AC 18 ms 4096 KB
01-16.txt AC 17 ms 4096 KB
01-17.txt AC 17 ms 4096 KB
01-18.txt AC 17 ms 4096 KB
01-19.txt AC 17 ms 4096 KB
02-01.txt RE
02-02.txt RE
02-03.txt RE
02-04.txt RE
02-05.txt RE
02-06.txt RE
02-07.txt RE
02-08.txt RE
02-09.txt RE
02-10.txt RE
02-11.txt RE
02-12.txt RE
02-13.txt RE
02-14.txt RE
02-15.txt RE
02-16.txt RE
sample-01.txt AC 1 ms 256 KB
sample-02.txt RE