結果
問題 | No.451 575 |
ユーザー |
|
提出日時 | 2020-03-02 23:34:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 188 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 571 ms |
コンパイル使用メモリ | 67,072 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 21:22:47 |
合計ジャッジ時間 | 4,885 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N; long B[1<<17],A[1<<17]; main() { cin>>N; for(int i=0;i<N;i++)cin>>B[i]; long cumsum=0; long T=2e18; long L=1,R=T/2; for(int i=0;i<N;i++) { if(i%4==0||i%4==3) { cumsum+=B[i]; } else { cumsum-=B[i]; } if(i%4<2) { L=max(L,cumsum-T/2); R=min(R,cumsum-1); } else { L=max(L,cumsum+1); R=min(R,cumsum+T/2); } if(L>R) { cout<<-1<<endl; return 0; } } cout<<N+1<<endl; cout<<L<<endl; for(int i=0;i<N;i++) { if(i%2==0) { L=B[i]-L; } else { L=L-B[i]; } cout<<L<<endl; } }