結果
問題 | No.1374 Absolute Game |
ユーザー |
![]() |
提出日時 | 2021-02-05 21:36:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 718 bytes |
コンパイル時間 | 2,868 ms |
コンパイル使用メモリ | 199,324 KB |
最終ジャッジ日時 | 2025-01-18 12:04:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 20 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 long long get(deque<long long> c,bool f0,bool f1){ long long a=0,b=0; while(c.size()!=0){ if(f0){ a += c.back(); c.pop_back(); } else{ a += c.front(); c.pop_front(); } if(c.size()==0)break; if(f1){ b += c.back(); c.pop_back(); } else{ b += c.front(); c.pop_front(); } } a = abs(a); b = abs(b); return a-b; } int main(){ int N; cin>>N; deque<long long> c(N); rep(i,N){ cin>>c[i]; } long long ans = max(min(get(c,true,false),get(c,true,true)),min(get(c,false,false),get(c,false,true))); cout<<ans<<endl; return 0; }