Submission #66121711
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
int read(){int f=0,x=0;char a=getchar();while(!isdigit(a)){if(a=='-')f=1;a=getchar();}while(isdigit(a)){x=x*10+a-'0';a=getchar();}if(f)return -x;return x;}
long long t,n;
int main()
{
//freopen(in.in,r,stdin);
//freopen(out.out,w,stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
while(t--)
{
cin>>n;
priority_queue<long long,vector<long long>,greater<long long> >q;
vector<long long>a(2*n+7),l(2*n+7),r(2*n+7);
long long sum=0,ans=0;
for(int i=1;i<=2*n;i++)cin>>a[i];
for(int i=1;i<=2*n;i++)
{
q.push(a[i]);
sum+=a[i];
if(q.size()>(i+1)/2)
{
sum-=q.top();
q.pop();
}
l[i]=sum;
}
sum=0;
priority_queue<long long,vector<long long>,greater<long long> >qq;
for(int i=2*n;i>=1;i--)
{
qq.push(a[i]);
sum+=a[i];
if(qq.size()>(2*n-i+2)/2)
{
sum-=qq.top();
qq.pop();
}
r[i]=sum;
}
for(int i=2;i<=2*n;i+=2)
{
ans=max(ans,l[i]+r[i+1]);
}
cout<<ans<<"\n";
}
return 0;
}
Submission Info
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:23:24: warning: comparison of integer expressions of different signedness: ‘std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
23 | if(q.size()>(i+1)/2)
| ~~~~~~~~^~~~~~~~
Main.cpp:36:25: warning: comparison of integer expressions of different signedness: ‘std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare]
36 | if(qq.size()>(2*n-i+2)/2)
| ~~~~~~~~~^~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
0 / 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 |
WA |
1 ms |
3448 KiB |
| 01-01.txt |
WA |
1 ms |
3540 KiB |
| 01-02.txt |
WA |
1 ms |
3536 KiB |
| 01-03.txt |
WA |
2 ms |
3464 KiB |
| 01-04.txt |
WA |
1 ms |
3400 KiB |
| 01-05.txt |
WA |
49 ms |
3560 KiB |
| 01-06.txt |
WA |
62 ms |
6844 KiB |
| 01-07.txt |
WA |
64 ms |
17192 KiB |
| 01-08.txt |
WA |
30 ms |
3628 KiB |
| 01-09.txt |
WA |
50 ms |
3472 KiB |
| 01-10.txt |
WA |
57 ms |
17276 KiB |
| 01-11.txt |
WA |
53 ms |
6780 KiB |
| 01-12.txt |
WA |
58 ms |
17260 KiB |
| 01-13.txt |
WA |
54 ms |
6876 KiB |
| 01-14.txt |
WA |
56 ms |
17160 KiB |
| 01-15.txt |
WA |
53 ms |
6828 KiB |
| 01-16.txt |
WA |
60 ms |
17160 KiB |
| 01-17.txt |
WA |
56 ms |
6816 KiB |