Submission #66127198


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include"atcoder/all"
using namespace atcoder;
typedef modint998244353 mi;
using namespace std;
#define all(a) a.begin(),a.end()
#define compress(a) sort(all(a));a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
constexpr ll mod=998244353;
constexpr ll inf=3e18;

void solve(){
	int n;
	cin>>n;
	vector<ll>a(n*2);
	rep(i,n*2)cin>>a[i];
	priority_queue<ll>pq;
	pq.push(a[0]);
	ll ans=0;
	rep(i,n){
		ans+=pq.top();
		pq.pop();
		pq.push(a[i*2+1]);
		pq.push(a[i*2+2]);
	}
	cout<<ans<<endl;

}

int main(){
	int t;
	cin>>t;
	rep(T,t)solve();
}

Submission Info

Submission Time
Task E - Most Valuable Parentheses
User Rho17
Language C++ 20 (gcc 12.2)
Score 450
Code Size 668 Byte
Status AC
Exec Time 117 ms
Memory 8448 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 1
AC × 18
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 3496 KiB
01-01.txt AC 2 ms 3588 KiB
01-02.txt AC 2 ms 3520 KiB
01-03.txt AC 2 ms 3676 KiB
01-04.txt AC 3 ms 3488 KiB
01-05.txt AC 110 ms 3468 KiB
01-06.txt AC 117 ms 4712 KiB
01-07.txt AC 117 ms 8316 KiB
01-08.txt AC 70 ms 3600 KiB
01-09.txt AC 111 ms 3512 KiB
01-10.txt AC 117 ms 8388 KiB
01-11.txt AC 116 ms 4732 KiB
01-12.txt AC 111 ms 8404 KiB
01-13.txt AC 111 ms 4720 KiB
01-14.txt AC 115 ms 8360 KiB
01-15.txt AC 115 ms 4772 KiB
01-16.txt AC 113 ms 8448 KiB
01-17.txt AC 113 ms 4760 KiB