実行時間制限: 2 sec / メモリ制限: 256 MB
配点 : 点
問題文
個のマスが一列に並んでおり、左から順に の番号が付けられています。 すぬけくんとりんごさんはこのマス目を使って、以下のようなボードゲームで遊ぼうとしています。
- はじめに、すぬけくんがすべてのマスに つずつ整数を書く。
- 人のプレイヤーはそれぞれ つずつ駒を用意し、すぬけくんは自分の駒をマス に、りんごさんは自分の駒をマス に置く。
- 自分の駒が相手の駒より左にあるプレイヤーが駒を動かす。駒を動かす先は、今自分の駒が置かれているマスよりも右にあってかつ相手の駒が置かれていないマスでなければならない。
- 3. を繰り返し、これ以上駒を動かすことができなくなるとゲームは終了となる。
- ゲーム終了時までに自分の駒を置いたことのあるマスに書かれた整数の合計が、それぞれのプレイヤーのスコアとなる。
すぬけくんはすでにマス に整数 を書きましたが、まだマス には整数を書いていません。 すぬけくんは 個の整数 それぞれについて、その数をマス に書いてゲームを行ったときに「(すぬけくんのスコア)ー(りんごさんのスコア)」がいくらになるのかを計算することにしました。 ただし、それぞれのプレイヤーは「(自分のスコア)ー(相手のスコア)」を最大化するように駒を動かすものとします。
制約
- の総和は 以下である。
部分点
- を満たすデータセットに正解した場合は、 点が与えられる。
- 追加制約のないデータセットに正解した場合は、上記とは別に 点が与えられる。
入力
入力は以下の形式で標準入力から与えられる。
出力
の 個の整数それぞれに対し、その数をマス に書いたときの「(すぬけくんのスコア)ー(りんごさんのスコア)」を 行にひとつずつ出力せよ。
入力例 1 Copy
5 2 7 1 8 1 2
出力例 1 Copy
0
ゲームは下図のように進行します。Sはすぬけくんの駒、Rはりんごさんの駒を表しています。
スコアは 人とも となり、「(すぬけくんのスコア)ー(りんごさんのスコア)」は となります。
入力例 2 Copy
9 2 0 1 6 1 1 2 6 5 2016 1 1 2 6
出力例 2 Copy
2001 6 6 7 7
Score : points
There are squares in a row, numbered through from left to right. Snuke and Rng are playing a board game using these squares, described below:
- Each of the two players possesses one piece. Snuke places his piece onto square , and Rng places his onto square .
Snuke has already written an integer into square , but not into square yet. He has decided to calculate for each of integers , if he writes it into square and the game is played, what the value "(Snuke's score) - (Rng's score)" will be. Here, it is assumed that each player moves his piece to maximize the value "(the player's score) - (the opponent's score)".
- The sum of all is at most .
- points will be awarded for passing the test set satisfying .
- Additional points will be awarded for passing the test set without additional constraints.
For each of the integers , print the value "(Snuke's score) - (Rng's score)" if it is written into square , one per line.
Both player scores , thus "(Snuke's score) - (Rng's score)" is .