結果
| 問題 |
No.999 てん vs. ほむ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-30 12:13:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,541 bytes |
| コンパイル時間 | 900 ms |
| コンパイル使用メモリ | 100,280 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-11 18:58:42 |
| 合計ジャッジ時間 | 2,172 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 12 |
ソースコード
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
#ifdef LOCAL
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#else
#define debug(x...)
#endif
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N;
cin >> N;
deque<ll> A(2 * N);
REP(i, 2 * N) cin >> A[i];
ll user_a = 0;
ll user_b = 0;
ll left = 0;
ll right = 2 * N - 1;
REP(i, N) {
ll left_score_diff = A[left] - A[left + 1];
ll right_score_diff = A[right] - A[right - 1];
debug(left_score_diff, right_score_diff);
if (left_score_diff >= right_score_diff) {
user_a += A[left];
user_b += A[left + 1];
left += 2;
} else { // right
user_a += A[right];
user_b += A[right - 1];
right -= 2;
}
debug(user_a, user_b, left, right);
}
debug(user_a, user_b);
cout << user_a - user_b << endl;
return 0;
}