Submission #3604066
Source Code Expand
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp //g++ -std=c++14 -Wall -O2 -o main.exe main.cpp #include <cstdio> #include <cstdlib> #include <cmath> #include <iostream> #include <iomanip> #include <string> #include <vector> #include <functional> #include <algorithm> #include <complex> #include <numeric> #include <queue> #include <stack> #include <tuple> using namespace std; #define ll long long int #define sortasc(v, T) sort(v.begin(), v.end(), less<T>()) #define sortdesc(v, T) sort(v.begin(), v.end(), greater<T>()) //------ int N; vector<int> A; int main(){ cin >> N; int t; for(int i = 0; i < N; i++){ cin >> t; A.push_back(t); } sortasc(A, int); vector<int> less1, more1; for(int i = 0; i < N; i++){ if(i < (N + 1) / 2){ less1.push_back(A[i]); } else{ more1.insert(more1.begin(), A[i]); } } less1.insert(less1.begin(), less1[less1.size() - 1]); int sum1 = 0; for(int i = 0; i < (N - 1); i++){ sum1 += more1[i / 2] - less1[(i + 1) / 2]; } sortdesc(A, int); vector<int> less2, more2; for(int i = 0; i < N; i++){ if(i < (N + 1) / 2){ less2.push_back(A[i]); } else{ more2.insert(more2.begin(), A[i]); } } less2.insert(less2.end(), less2[0]); int sum2 = 0; for(int i = 0; i < (N - 1); i++){ sum2 += less2[(i + 1) / 2] - more2[i / 2]; } // printf("%d, %d\n", sum1, sum2); cout << max(sum1, sum2) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Align |
User | Esire |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1663 Byte |
Status | WA |
Exec Time | 390 ms |
Memory | 1656 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 390 ms | 1656 KB |
02.txt | WA | 386 ms | 1656 KB |
03.txt | WA | 388 ms | 1656 KB |
04.txt | WA | 387 ms | 1656 KB |
05.txt | WA | 388 ms | 1656 KB |
06.txt | WA | 387 ms | 1656 KB |
07.txt | WA | 387 ms | 1656 KB |
08.txt | WA | 388 ms | 1656 KB |
09.txt | WA | 388 ms | 1656 KB |
10.txt | WA | 387 ms | 1656 KB |
11.txt | WA | 387 ms | 1656 KB |
12.txt | WA | 389 ms | 1656 KB |
13.txt | WA | 387 ms | 1656 KB |
14.txt | WA | 387 ms | 1656 KB |
15.txt | WA | 387 ms | 1656 KB |
16.txt | WA | 387 ms | 1656 KB |
17.txt | WA | 387 ms | 1656 KB |
18.txt | WA | 387 ms | 1656 KB |
19.txt | WA | 388 ms | 1656 KB |
20.txt | WA | 387 ms | 1656 KB |
21.txt | WA | 378 ms | 1656 KB |
22.txt | WA | 378 ms | 1656 KB |
23.txt | WA | 378 ms | 1656 KB |
24.txt | WA | 378 ms | 1656 KB |
25.txt | AC | 361 ms | 1656 KB |
26.txt | AC | 360 ms | 1656 KB |
27.txt | AC | 360 ms | 1656 KB |
28.txt | AC | 360 ms | 1656 KB |
29.txt | AC | 358 ms | 1656 KB |
30.txt | WA | 373 ms | 1656 KB |
31.txt | WA | 372 ms | 1656 KB |
32.txt | WA | 372 ms | 1656 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 1 ms | 256 KB |
35.txt | AC | 1 ms | 256 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |