Submission #1692141
Source Code Expand
//mokoちゃん解 #include <bits/stdc++.h> #include <stdio.h> using namespace std; #define INF 2147483647 #define LINF 9223372036854775807 #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(), (v).end() typedef long long ll; typedef pair<ll, int> P; int n; ll a[300000]; priority_queue<ll,vector<ll>,greater<ll> > mi; priority_queue<ll> ma; ll front[300000],back[300000]; ll sf,sb,ans=-LINF; int main(){ cin.tie(0); ios::sync_with_stdio(false); cin>>n; REP(i,3*n) { cin>>a[i]; if(i<n) { mi.push(a[i]); sf+=a[i]; } if(i>=2*n) { ma.push(a[i]); sb+=a[i]; } } front[n-1]=sf; FOR(i,n,2*n) { mi.push(a[i]); sf+=(a[i]-mi.top()); mi.pop(); front[i]=sf; } back[2*n-1]=sb; for(int i=2*n-2;i>=n-1;i--) { ma.push(a[i+1]); sb+=(a[i+1]-ma.top()); ma.pop(); back[i]=sb; ans=max(ans,front[i]-back[i]); } //----- ans=max(ans,front[2*n-1]-back[2*n-1]); //------- cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Grouping |
User | Nafmo2 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1053 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 4352 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt |
All | 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 2 ms | 4352 KB |
0_01.txt | WA | 2 ms | 4352 KB |
1_00.txt | WA | 2 ms | 4352 KB |
1_01.txt | WA | 2 ms | 4352 KB |
1_02.txt | WA | 2 ms | 4352 KB |
1_03.txt | WA | 2 ms | 4352 KB |
1_04.txt | WA | 2 ms | 4352 KB |