Submission #1691716
Source Code Expand
#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[100000]; bool flg[100000]; vector<ll> mi; vector<P> ma; int main(){ cin.tie(0); ios::sync_with_stdio(false); cin>>n; REP(i,3*n) { cin>>a[i]; if(i<n) mi.push_back(a[i]); else ma.push_back(P(a[i],i)); } sort(ALL(ma)); sort(mi.rbegin(),mi.rend()); ll ans=-LINF,l=0,r=0; FOR(idx,n,2*n) { l=0,r=0; REP(i,n) l+=mi[i]; REP(i,n) r+=ma[i].first; ans=max(ans,l-r); auto itr=find(ALL(ma),P(a[idx],idx)); ma.erase(itr); mi.push_back(a[idx]); sort(mi.rbegin(),mi.rend()); } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 3N Numbers |
User | moko_freedom |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 871 Byte |
Status | RE |
Exec Time | 115 ms |
Memory | 1912 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | 0 / 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 | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | WA | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | WA | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 15 ms | 384 KB |
1_09.txt | AC | 15 ms | 384 KB |
1_10.txt | AC | 15 ms | 384 KB |
1_11.txt | WA | 15 ms | 384 KB |
1_12.txt | AC | 15 ms | 384 KB |
1_13.txt | WA | 15 ms | 384 KB |
1_14.txt | AC | 15 ms | 384 KB |
1_15.txt | AC | 15 ms | 384 KB |
1_16.txt | AC | 16 ms | 384 KB |
1_17.txt | AC | 16 ms | 384 KB |
1_18.txt | AC | 15 ms | 384 KB |
1_19.txt | AC | 15 ms | 384 KB |
1_20.txt | AC | 18 ms | 384 KB |
1_21.txt | AC | 19 ms | 384 KB |
1_22.txt | AC | 19 ms | 384 KB |
1_23.txt | AC | 19 ms | 384 KB |
2_00.txt | AC | 10 ms | 1912 KB |
2_01.txt | RE | 113 ms | 1912 KB |
2_02.txt | RE | 107 ms | 1912 KB |
2_03.txt | RE | 105 ms | 1912 KB |
2_04.txt | WA | 14 ms | 1912 KB |
2_05.txt | RE | 109 ms | 1912 KB |
2_06.txt | WA | 15 ms | 1912 KB |
2_07.txt | RE | 108 ms | 1912 KB |
2_08.txt | WA | 12 ms | 1912 KB |
2_09.txt | WA | 12 ms | 1912 KB |
2_10.txt | WA | 11 ms | 1912 KB |
2_11.txt | WA | 11 ms | 1912 KB |
2_12.txt | RE | 107 ms | 1912 KB |
2_13.txt | RE | 113 ms | 1912 KB |
2_14.txt | RE | 115 ms | 1912 KB |
2_15.txt | RE | 108 ms | 1912 KB |