結果
| 問題 |
No.451 575
|
| コンテスト | |
| ユーザー |
chaemon
|
| 提出日時 | 2016-12-02 00:33:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,045 bytes |
| コンパイル時間 | 917 ms |
| コンパイル使用メモリ | 81,004 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 07:45:54 |
| 合計ジャッジ時間 | 7,402 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 WA * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:103:27: warning: ‘a’ may be used uninitialized in this function [-Wmaybe-uninitialized]
103 | a = b[i] - a;
| ~~^~~~~~~~~~
ソースコード
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define EXIST(e,s) ((s).find(e)!=(s).end())
#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command
const int INF=0x3f3f3f3f;
typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif
typedef pair<int,int> pii;
/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}
const Int m = 1, M = 1000000000000000000ll;
int main(){
int n;
cin>>n;
vector<Int> b(n);
REP(i,n)cin>>b[i];
pair<Int,Int> v(0,1);//const, a_0
Int a;
REP(i,n){
//judge
pair<Int,Int> v2;
if(i%2==0){
v2.first = -v.first;
v2.second = -v.second;
v2.first+=b[i];
}else{
v2.first = v.first;
v2.second = v.second;
v2.first-=b[i];
}
// cerr<<v2.first<<" "<<v2.second<<endl;
v = v2;
Int l,r;
if(v.second==1){
l = m-v.first, r = M-v.first;
l = max(m,l);
r = min(M,r);
if(l>r){
cout<<-1<<endl;
return 0;
}
}else if(v.second==-1){
l = -(M-v.first), r = -(m-v.first);
l = max(m,l);
r = min(M,r);
if(l>r){
cout<<-1<<endl;
return 0;
}
}
if(i==n-1)a = l;
}
cout<<n+1<<endl;
REP(i,n){
cout<<a<<endl;
if(i%2==0){
a = b[i] - a;
}else{
a = a - b[i];
}
}
cout<<a<<endl;
return 0;
}
chaemon