結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
|
提出日時 | 2020-02-29 11:15:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 911 bytes |
コンパイル時間 | 982 ms |
コンパイル使用メモリ | 101,536 KB |
最終ジャッジ日時 | 2025-01-09 03:33:04 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
ソースコード
/* _/ _/ _/_/_/ _/ _/_/_/_/ _/_/ _/_/_/_/ _/_/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/_/ _/_/ _/_/ _/_/ _/ */ #include<iostream> #include<algorithm> #include<cmath> #include<iomanip> #include<set> #include<map> #include<queue> #include<vector> using namespace std; using ll=long long; const int MOD=1e9+7; const double pi=3.14159265358979323846; const int inf=2e9; const ll INF=1e18; using P=pair<int,int>; int main() { cin.tie(0),cout.tie(0); ios::sync_with_stdio(false); ll n,l,r,ans=0,a[200005]={}; cin >> n; for(int i=0; i<2*n; i++) { cin >> a[i]; } l=0,r=2*n-1; while(l<r) { if(a[l]-a[l+1]>=a[r]-a[r-1]) { ans+=a[l]-a[l+1]; l+=2; } else { ans+=a[r]-a[r-1]; r-=2; } } cout << ans << endl; }