Submission #1692142
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 | D - 3N Numbers |
User | Nafmo2 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1053 Byte |
Status | AC |
Exec Time | 56 ms |
Memory | 7796 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 200 / 200 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
Subtask | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 4352 KB |
0_01.txt | AC | 2 ms | 4352 KB |
0_02.txt | AC | 2 ms | 4352 KB |
1_00.txt | AC | 2 ms | 4352 KB |
1_01.txt | AC | 2 ms | 4352 KB |
1_02.txt | AC | 2 ms | 4352 KB |
1_03.txt | AC | 2 ms | 4352 KB |
1_04.txt | AC | 2 ms | 4352 KB |
1_05.txt | AC | 2 ms | 4352 KB |
1_06.txt | AC | 2 ms | 4352 KB |
1_07.txt | AC | 2 ms | 4352 KB |
1_08.txt | AC | 2 ms | 4352 KB |
1_09.txt | AC | 2 ms | 4352 KB |
1_10.txt | AC | 2 ms | 4352 KB |
1_11.txt | AC | 2 ms | 4352 KB |
1_12.txt | AC | 2 ms | 4352 KB |
1_13.txt | AC | 2 ms | 4352 KB |
1_14.txt | AC | 2 ms | 4352 KB |
1_15.txt | AC | 2 ms | 4352 KB |
1_16.txt | AC | 2 ms | 4352 KB |
1_17.txt | AC | 2 ms | 4352 KB |
1_18.txt | AC | 2 ms | 4352 KB |
1_19.txt | AC | 2 ms | 4352 KB |
1_20.txt | AC | 2 ms | 4352 KB |
1_21.txt | AC | 2 ms | 4352 KB |
1_22.txt | AC | 2 ms | 4352 KB |
1_23.txt | AC | 2 ms | 4352 KB |
2_00.txt | AC | 27 ms | 7796 KB |
2_01.txt | AC | 41 ms | 7796 KB |
2_02.txt | AC | 40 ms | 7796 KB |
2_03.txt | AC | 40 ms | 7796 KB |
2_04.txt | AC | 41 ms | 7796 KB |
2_05.txt | AC | 40 ms | 7796 KB |
2_06.txt | AC | 40 ms | 7796 KB |
2_07.txt | AC | 40 ms | 7796 KB |
2_08.txt | AC | 32 ms | 7668 KB |
2_09.txt | AC | 32 ms | 7668 KB |
2_10.txt | AC | 33 ms | 7668 KB |
2_11.txt | AC | 32 ms | 7668 KB |
2_12.txt | AC | 56 ms | 7668 KB |
2_13.txt | AC | 56 ms | 7796 KB |
2_14.txt | AC | 56 ms | 7796 KB |
2_15.txt | AC | 56 ms | 7668 KB |