結果
問題 | No.451 575 |
ユーザー |
![]() |
提出日時 | 2016-12-02 00:47:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 205 ms / 2,000 ms |
コード長 | 2,009 bytes |
コンパイル時間 | 776 ms |
コンパイル使用メモリ | 82,704 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 09:44:32 |
合計ジャッジ時間 | 4,148 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:96:27: warning: ‘a’ may be used uninitialized in this function [-Wmaybe-uninitialized] 96 | a = a - b[i]; main.cpp:75:23: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] 75 | Int l,r; | ^ main.cpp:75:21: warning: ‘l’ may be used uninitialized in this function [-Wmaybe-uninitialized] 75 | Int l,r; | ^
ソースコード
// #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 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 pair<Int,Int> rng(m,M); 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; // cout<<v.first<<" "<<v.second<<endl; Int l,r; if(v.second==1){ l = m-v.first, r = M-v.first; }else if(v.second==-1){ l = v.first-M, r = v.first-m; } rng.first=max(rng.first,l); rng.second=min(rng.second,r); if(rng.first>rng.second){ cout<<-1<<endl; return 0; } if(i==n-1)a = rng.first; } cout<<n+1<<endl; REP(i,n){ cout<<a<<endl; assert(m<=a and a<=M); if(i%2==0){ a = b[i] - a; }else{ a = a - b[i]; } } cout<<a<<endl; assert(m<=a and a<=M); return 0; }