結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
|
提出日時 | 2020-02-28 21:33:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,559 bytes |
コンパイル時間 | 861 ms |
コンパイル使用メモリ | 108,284 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 16:53:21 |
合計ジャッジ時間 | 2,026 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <map> #include <set> #include <tuple> #include <deque> #include <numeric> #include <bitset> #include <iomanip> #include <cassert> #include <chrono> #include <random> #include <limits> #include <iterator> #include <functional> #include <sstream> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<int, double> Pid; typedef pair<double, int> Pdi; typedef pair<ll, int> Pl; typedef pair<int, pair<int, int>> PP; const double PI = 3.1415926535897932; // acos(-1) const double EPS = 1e-15; const int INF = 1001001001; const int mod = 1e+9 + 7; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define chadd(x, y) x = (x + y) % mod int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int sz = n * 2; vector<ll> a(sz); for(int i = 0; i < sz; ++i) cin >> a[i]; int left = 0, right = sz - 1; ll res = 0; int remain = sz; while(remain > 2){ ll foo = a[left] - a[left + 1]; ll bar = a[right] - a[right - 1]; if(foo >= bar){ res += foo; left = left + 2; } else{ res += bar; right = right - 2; } remain -= 2; } if(remain % 2 == 0){ ll foo = a[left] - a[right]; ll bar = a[right] - a[left]; res += max(foo, bar); } else{ res += a[left]; } cout << res << endl; }