Please sign in first.
Submission #66193076
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
void solve() {
int n;
cin >> n;
vector<int> a(2 * n + 1);
for(int i = 1; i <= 2 * n; i++) {
cin >> a[i];
}
priority_queue<int> heap;
i64 ans = 0;
for(int i = 1; i <= 2 * n; i++) {
heap.push(a[i]);
if(i & 1) {
ans += heap.top();
heap.pop();
}
}
cout << ans << '\n';
}
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Most Valuable Parentheses |
| User | dengstar |
| Language | C++ 20 (gcc 12.2) |
| Score | 450 |
| Code Size | 621 Byte |
| Status | AC |
| Exec Time | 42 ms |
| Memory | 5792 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 450 / 450 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt |
| All | 00-sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3540 KiB |
| 01-01.txt | AC | 1 ms | 3500 KiB |
| 01-02.txt | AC | 1 ms | 3500 KiB |
| 01-03.txt | AC | 1 ms | 3416 KiB |
| 01-04.txt | AC | 1 ms | 3520 KiB |
| 01-05.txt | AC | 36 ms | 3372 KiB |
| 01-06.txt | AC | 40 ms | 3992 KiB |
| 01-07.txt | AC | 42 ms | 5792 KiB |
| 01-08.txt | AC | 22 ms | 3528 KiB |
| 01-09.txt | AC | 36 ms | 3440 KiB |
| 01-10.txt | AC | 41 ms | 5640 KiB |
| 01-11.txt | AC | 39 ms | 3816 KiB |
| 01-12.txt | AC | 34 ms | 5788 KiB |
| 01-13.txt | AC | 33 ms | 3956 KiB |
| 01-14.txt | AC | 39 ms | 5604 KiB |
| 01-15.txt | AC | 37 ms | 3860 KiB |
| 01-16.txt | AC | 38 ms | 5704 KiB |
| 01-17.txt | AC | 36 ms | 4040 KiB |