Submission #3483457
Source Code Expand
/** * File : C.cpp * Author : Kazune Takahashi * Created : 2018-10-27 20:57:45 * Powered by Visual Studio Code */ #include <iostream> #include <iomanip> // << fixed << setprecision(xxx) #include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ; #include <vector> #include <string> // to_string(nnn) // substr(m, n) // stoi(nnn) #include <complex> #include <tuple> #include <queue> #include <stack> #include <map> // if (M.find(key) != M.end()) { } #include <set> #include <functional> #include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725)); #include <chrono> // std::chrono::system_clock::time_point start_time, end_time; // start = std::chrono::system_clock::now(); // double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count(); #include <cctype> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> using namespace std; #define DEBUG 0 // change 0 -> 1 if we need debug. typedef long long ll; // const int dx[4] = {1, 0, -1, 0}; // const int dy[4] = {0, 1, 0, -1}; // const int C = 1e6+10; // const ll M = 1000000007; int N; vector<ll> X; vector<ll> A; ll start = 0; ll B[100010]; ll ans = 0; void solve() { for (auto i = 0; i < N - 1; i++) { if (i % 2 == 0) { B[i] = A[i / 2]; } else { B[i] = A[N - 1 - i / 2 - 1]; } } ll sum = abs(start - B[0]); for (auto i = 0; i < N - 2; i++) { // cerr << "B[" << i << "] = " << B[i] << endl; sum += abs(B[i] - B[i + 1]); } ans = max(ans, sum); } int main() { cin >> N; for (auto i = 0; i < N; i++) { ll x; cin >> x; X.push_back(x); } for (auto i = max(0, N / 2 - 1); i < min(N, N / 2 + 2); i++) { start = X[i]; A.clear(); for (auto j = 0; j < N; j++) { if (j != i) { A.push_back(X[j]); } } sort(A.begin(), A.end()); solve(); reverse(A.begin(), A.end()); solve(); } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Align |
User | kazunetakahashi |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2101 Byte |
Status | WA |
Exec Time | 70 ms |
Memory | 2676 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 | 62 ms | 2676 KB |
02.txt | WA | 62 ms | 2676 KB |
03.txt | WA | 62 ms | 2676 KB |
04.txt | WA | 62 ms | 2676 KB |
05.txt | WA | 62 ms | 2676 KB |
06.txt | WA | 62 ms | 2676 KB |
07.txt | WA | 61 ms | 2676 KB |
08.txt | WA | 62 ms | 2676 KB |
09.txt | WA | 62 ms | 2676 KB |
10.txt | WA | 62 ms | 2676 KB |
11.txt | WA | 70 ms | 2676 KB |
12.txt | WA | 62 ms | 2676 KB |
13.txt | WA | 62 ms | 2676 KB |
14.txt | WA | 61 ms | 2676 KB |
15.txt | WA | 61 ms | 2676 KB |
16.txt | WA | 62 ms | 2676 KB |
17.txt | WA | 62 ms | 2676 KB |
18.txt | WA | 62 ms | 2676 KB |
19.txt | WA | 61 ms | 2676 KB |
20.txt | WA | 61 ms | 2676 KB |
21.txt | WA | 53 ms | 2676 KB |
22.txt | WA | 53 ms | 2676 KB |
23.txt | WA | 53 ms | 2676 KB |
24.txt | WA | 53 ms | 2676 KB |
25.txt | AC | 28 ms | 2676 KB |
26.txt | WA | 27 ms | 2676 KB |
27.txt | WA | 28 ms | 2676 KB |
28.txt | WA | 27 ms | 2676 KB |
29.txt | AC | 23 ms | 2676 KB |
30.txt | AC | 37 ms | 2676 KB |
31.txt | AC | 37 ms | 2676 KB |
32.txt | AC | 37 ms | 2676 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 |