結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-03-05 12:45:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 735 bytes |
コンパイル時間 | 1,757 ms |
コンパイル使用メモリ | 167,820 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 00:58:06 |
合計ジャッジ時間 | 3,007 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--) using namespace std; using ll = long long; using Int = long long; const int MOD = 1000000007; const ll INF = numeric_limits<ll>::max(); const int inf = 1e8; //少数点表示 //cout <<std::fixed << std::setprecision(14) int main(){ cin.tie( 0 ); ios::sync_with_stdio( false ); int n; cin >> n; vector<ll> a(n*2); rep(i,2*n) cin >> a[i]; int r=(2*n)-1,l=0; ll ans=0; while(r-l>0){ 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; }