結果

問題 No.451 575
ユーザー alpha_virginisalpha_virginis
提出日時 2016-12-03 22:28:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 165,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 19:08:26
合計ジャッジ時間 4,274 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 18 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 19 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 17 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int n;
long xs[112345];
long ys[112345];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%ld", &xs[i]);
  }

  ys[0] = 1;
  int prev = 1;
  for(int i = 0; i < n; ++i) {
    long y = i % 2 == 0 ? xs[i] - prev : prev - xs[i];
    ys[i+1] = y;
    prev = y;
  }

  bool check = true;
  for(int i = 0; i < n + 1; ++i) {
    if( ys[i] <= 0 ) check = false;
  }

  if( check ) {
    printf("%d\n", n + 1);
    for(int i = 0; i < n + 1; ++i) {
      printf("%ld\n", ys[i]);
    }
  }
  else {
    printf("-1\n");
  }
      

  return 0;
}
0