Submission #66139349
Source Code Expand
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bits/stdc++.h>
#define int long long
#define jiaa(a,b) {a+=b;if(a>=MOD) a-=MOD;}
#define jian(a,b) {a-=b;if(a<0) a+=MOD;}
using namespace std;
int ksm(int a,int b,int p){
if(b==0) return 1;
if(b==1) return a%p;
int c=ksm(a,b/2,p);
c=c*c%p;
if(b%2==1) c=c*a%p;
return c%p;
}
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
int a[1000005];
priority_queue<int> ht;
signed main()
{
//freopen("filename.in", "r", stdin);
//freopen("filename.out", "w", stdout);
int T=read();
while(T--){
int n=read()*2;
for(int i=1;i<=n;i++) a[i]=read();
int ans=a[1];
for(int i=2;i<n;i+=2){
ht.push(a[i]);
ht.push(a[i+1]);
ans+=ht.top();
ht.pop();
}
while(!ht.empty()) ht.pop();
cout<<ans<<'\n';
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Most Valuable Parentheses |
| User | gbrrain |
| Language | C++ 20 (gcc 12.2) |
| Score | 450 |
| Code Size | 1040 Byte |
| Status | AC |
| Exec Time | 50 ms |
| Memory | 8368 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 | 3608 KiB |
| 01-01.txt | AC | 1 ms | 3488 KiB |
| 01-02.txt | AC | 1 ms | 3408 KiB |
| 01-03.txt | AC | 1 ms | 3604 KiB |
| 01-04.txt | AC | 1 ms | 3476 KiB |
| 01-05.txt | AC | 33 ms | 3484 KiB |
| 01-06.txt | AC | 45 ms | 4600 KiB |
| 01-07.txt | AC | 50 ms | 8180 KiB |
| 01-08.txt | AC | 21 ms | 3492 KiB |
| 01-09.txt | AC | 35 ms | 3504 KiB |
| 01-10.txt | AC | 43 ms | 8212 KiB |
| 01-11.txt | AC | 38 ms | 4600 KiB |
| 01-12.txt | AC | 39 ms | 8268 KiB |
| 01-13.txt | AC | 35 ms | 4572 KiB |
| 01-14.txt | AC | 45 ms | 8368 KiB |
| 01-15.txt | AC | 40 ms | 4580 KiB |
| 01-16.txt | AC | 42 ms | 8264 KiB |
| 01-17.txt | AC | 37 ms | 4628 KiB |