Submission #1518199
Source Code Expand
#include <iostream> #include <string> #include <algorithm> #include <cstdio> #include <vector> #include <queue> #include <set> #include <numeric> #include <cmath> using namespace std; typedef long long int lld; const lld mod = 1e9+7; const lld INF = 1e9; const lld MAXN = 1e3; int main() { lld n,a[MAXN * 3] = {}; cin >> n; for(int i = 0; i < 3 * n; i++) { cin >> a[i]; } lld s[MAXN * 3] = {}; s[0] = a[0]; for(int i = 1; i < 3*n; i++) { s[i] = s[i-1] + a[i]; } lld sum = s[3 * n - 1]; //cout << sum << endl; lld z = -INF; lld p = n-1; for(int i = n-1; i < 2*n; i++) { lld x = 2 * s[i] - sum; if (z < x) { z = x; p = i; } } //cout << "p = " << p << endl; vector<lld> b,c; for(int i = 0; i < p; i++) { b.push_back(a[i]); //cout << a[i] << " "; } //printf("\n"); for(int i = p; i < 3 * n; i++) { c.push_back(a[i]); //cout << a[i] << " "; } //printf("\n"); sort(b.begin(),b.end(),greater<lld>()); sort(c.begin(),c.end()); lld left = 0; // for(int i = 0; i < b.size(); i++) // { // cout << b[i] << " "; // } // printf("\n"); // for(int i = 0; i < c.size(); i++) // { // cout << c[i] << " "; // } // printf("\n"); for(int i = 0; i < n; i++) { left += b[i]; } lld right = 0; for(int i = 0; i < n; i++) { right += c[i]; } cout << left - right << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 3N Numbers |
User | ykmaku |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1467 Byte |
Status | RE |
Exec Time | 99 ms |
Memory | 384 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 | 2 ms | 384 KB |
1_09.txt | AC | 2 ms | 256 KB |
1_10.txt | WA | 2 ms | 384 KB |
1_11.txt | WA | 2 ms | 256 KB |
1_12.txt | WA | 2 ms | 384 KB |
1_13.txt | WA | 2 ms | 384 KB |
1_14.txt | WA | 2 ms | 384 KB |
1_15.txt | AC | 2 ms | 384 KB |
1_16.txt | WA | 2 ms | 384 KB |
1_17.txt | WA | 2 ms | 256 KB |
1_18.txt | WA | 2 ms | 384 KB |
1_19.txt | WA | 2 ms | 384 KB |
1_20.txt | WA | 2 ms | 256 KB |
1_21.txt | WA | 2 ms | 256 KB |
1_22.txt | WA | 2 ms | 384 KB |
1_23.txt | WA | 2 ms | 256 KB |
2_00.txt | RE | 97 ms | 256 KB |
2_01.txt | RE | 98 ms | 256 KB |
2_02.txt | RE | 96 ms | 256 KB |
2_03.txt | RE | 96 ms | 256 KB |
2_04.txt | RE | 97 ms | 256 KB |
2_05.txt | RE | 97 ms | 256 KB |
2_06.txt | RE | 99 ms | 256 KB |
2_07.txt | RE | 99 ms | 256 KB |
2_08.txt | RE | 98 ms | 256 KB |
2_09.txt | RE | 96 ms | 256 KB |
2_10.txt | RE | 96 ms | 256 KB |
2_11.txt | RE | 96 ms | 256 KB |
2_12.txt | RE | 98 ms | 256 KB |
2_13.txt | RE | 97 ms | 256 KB |
2_14.txt | RE | 98 ms | 256 KB |
2_15.txt | RE | 97 ms | 256 KB |