Submission #4020507
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; int main(){ ios::sync_with_stdio(false); cin.tie(0); int x, y; cin >> n >> x >> y; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << abs(a[0] - y) << endl; return 0; } if (n == 2) { cout << max(abs(a[0]-a[1]), abs(a[1] - y)); return 0; } sort(a+1,a+n-1); int ans = abs(a[n - 1] - a[1]); ans = max(ans, abs(max(a[0],a[n-2]) - a[n-1])); ans = max(ans, abs(a[n-1] - y)); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - ABS |
User | xuelei |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 587 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_0, example_1, example_2, example_3 |
All | example_0, example_1, example_2, example_3, one_0, one_1, one_2, one_3, one_4, one_5, one_6, one_7, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_0 | AC | 1 ms | 256 KB |
example_1 | AC | 1 ms | 256 KB |
example_2 | AC | 1 ms | 256 KB |
example_3 | AC | 1 ms | 256 KB |
one_0 | AC | 1 ms | 256 KB |
one_1 | AC | 1 ms | 256 KB |
one_2 | AC | 1 ms | 256 KB |
one_3 | AC | 1 ms | 256 KB |
one_4 | AC | 1 ms | 256 KB |
one_5 | AC | 1 ms | 256 KB |
one_6 | AC | 1 ms | 256 KB |
one_7 | AC | 1 ms | 256 KB |
rand_0 | WA | 2 ms | 256 KB |
rand_1 | WA | 1 ms | 256 KB |
rand_10 | WA | 2 ms | 256 KB |
rand_11 | WA | 1 ms | 256 KB |
rand_12 | WA | 2 ms | 256 KB |
rand_13 | WA | 2 ms | 256 KB |
rand_14 | WA | 2 ms | 256 KB |
rand_15 | WA | 1 ms | 256 KB |
rand_2 | WA | 2 ms | 256 KB |
rand_3 | WA | 2 ms | 256 KB |
rand_4 | WA | 2 ms | 256 KB |
rand_5 | WA | 2 ms | 256 KB |
rand_6 | WA | 2 ms | 256 KB |
rand_7 | WA | 2 ms | 256 KB |
rand_8 | WA | 2 ms | 256 KB |
rand_9 | WA | 2 ms | 256 KB |