結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-02-28 21:25:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 584 bytes |
コンパイル時間 | 1,327 ms |
コンパイル使用メモリ | 169,548 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 16:39:12 |
合計ジャッジ時間 | 3,073 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
ソースコード
#include<bits/stdc++.h> #define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i) #define rep(i,a,b) for(int i=int(a);i<int(b);++i) #define All(x) (x).begin(),(x).end() #define rAll(x) (x).rbegin(),(x).rend() using namespace std; using ll = long long; int main(){ int N;cin>>N; vector<ll> A(2*N); REP(i,2*N) cin>>A[i]; int l=0,r=2*N-1; ll ans=0; while(l<r){ ll L = A[l]-A[l+1],R = A[r]-A[r-1]; if(L>R){ ans+=L; l+=2; } else{ ans+=R; r-=2; } } cout<<ans<<endl; }