結果
問題 | No.451 575 |
ユーザー |
![]() |
提出日時 | 2016-12-02 01:05:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,196 bytes |
コンパイル時間 | 1,857 ms |
コンパイル使用メモリ | 170,700 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-16 09:09:37 |
合計ジャッジ時間 | 5,551 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long using ll=long long; using vi=vector<int>; using vl=vector<long long>; using pii=pair<int,int>; using pll=pair<ll,ll>; #define ITR(v,c) for(auto v=begin(c);v!=end(c);++v) #define FORE(x,c) for(auto &x:c) #define FOR(v,a,n) for(int v=a;v<(int)(n);++v) #define REP(v,n) FOR(v,0,n) #define RREP(v,n) for(int v=((int)(n)-1);v>=0;--v) #define ALL(c) begin(c),end(c) #define RALL(c) rbegin(c),rend(c) #define SZ(c) ((int)c.size()) #define dump(...) const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0}; const int INF=1e9*2; const long long INFLL=1e18*2; template<class T> ostream& operator << (ostream &os, const vector<T> &v) { ITR(i,v) os<<*i<<(i==end(v)-1?"":"\n"); return os; } template<class T> istream& operator >> (istream &is, vector<T> &v) { ITR(i,v) is>>*i; return is; } //------------------------------------------------------------------------------ signed main() { int n; cin>>n; vi b(n); cin>>b; ll left=1,m,right=1e18; while(1) { m=(left+right)/2; vi a(n+1,0); a[0]=m; a[1]=b[0]-m; if(a[1]<1) { if(right==m) goto end; right=m; goto next; } FOR(i,2,n+1) { if(i%2==0) { a[i]=a[i-1]-b[i-1]; if(a[i]<1) { if(right==m) goto end; right=m; goto next; } if(a[i]>1e18) { if(left==m) goto end; left=m; goto next; } } else { a[i]=b[i-1]-a[i-1]; if(a[i]<1) { if(left==m) goto end; left=m; goto next; } if(a[i]>1e18) { if(right==m) goto end; right=m; goto next; } } } { cout<<n+1<<endl; cout<<a<<endl; return 0; } next:; } end: cout<<-1<<endl; return 0; }