結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-02-28 21:30:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 436 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 64,588 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 16:49:31 |
合計ジャッジ時間 | 2,178 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; int main(){ int n; cin>>n; ll a[2*n]; for(int i=0;i<2*n;i++) cin>>a[i]; // h t h t h t h t // + - + - + - + - // + - + - + - - + // h t h t h t t h // h t h t t h t h ll an, sm=0; for(int i=0,j=1;i<2*n;i++,j*=-1) { sm+=a[i]*j; } an = sm; for(int i=2*(n-1); i>=0; i-=2) { sm-=a[i] - a[i+1]; sm+=-a[i] + a[i+1]; an = max(an, sm); } cout<<an<<endl; }