mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:08:47 +00:00
B - Bracket Score
https://atcoder.jp/contests/agc048/submissions/31606165
This commit is contained in:
parent
acdb922081
commit
e08a844726
42
AtCoder/AGC048/B/B.cpp
Normal file
42
AtCoder/AGC048/B/B.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
int n, a[N], b[N];
|
||||
long long ans;
|
||||
std::priority_queue<int> q1, q2;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
|
||||
ans += a[i];
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> b[i];
|
||||
|
||||
(!(i & 1) ? q1 : q2).push(b[i] - a[i]);
|
||||
}
|
||||
|
||||
while (!q1.empty()) {
|
||||
int t = q1.top() + q2.top();
|
||||
q1.pop(), q2.pop();
|
||||
|
||||
if (t <= 0) break;
|
||||
ans += t;
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user