結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-02-28 21:32:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 699 bytes |
コンパイル時間 | 1,363 ms |
コンパイル使用メモリ | 169,588 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 16:51:20 |
合計ジャッジ時間 | 3,065 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(),(a).end() #define rALL(a) (a).rbegin(),(a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; int main() { int64_t N, ans = 0; cin >> N; vector<int64_t> A(2 * N); for (int i = 0; i < 2 * N; i++){ cin >> A.at(i); } int64_t left = 0, right = 2 * N - 1; for (int i = 0; i < N; i++){ if (A.at(left) - A.at(left + 1) < A.at(right) - A.at(right - 1)){ ans += A.at(right) - A.at(right - 1); right -= 2; } else { ans += A.at(left) - A.at(left + 1); left += 2; } } cout << ans << endl; }