Submission #2384331
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <unordered_map> #include <unordered_set> #include <cmath> #include <cstdio> #include <map> #include <set> #include <utility> #include <string> #include <functional> #include <queue> #include <stack> using namespace std; typedef long long ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n); int i, j; for(i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); if(a[n - 1] % 2 == 0) { int mid = a[0] / 2; int e = -1, mind = 1e9 + 1; for(i = 0; i < n - 1; i++) { if(abs(mid - a[i]) < mind) { mind = abs(mid - a[i]); e = a[i]; } } swap(e, a[n - 1]); cout << e << " " << a[n - 1]; } else { int m1 = a[n - 1] / 2; int m2 = m1 + 1; int mind = 1e9 + 1; int e; for(i = 0; i < n - 1; i++) { if(abs(m1 - a[i]) < mind) { mind = abs(m1 - a[i]); e = a[i]; } if(abs(m2 - a[i]) < mind) { mind = abs(m2 - a[i]); e = a[i]; } } swap(e, a[n - 1]); cout << e << " " << a[n - 1]; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Binomial Coefficients |
User | infomaniac |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1440 Byte |
Status | WA |
Exec Time | 17 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt |
All | even0.txt, even1.txt, float.txt, odd0.txt, odd1.txt, rnd_0.txt, rnd_1.txt, rnd_2.txt, rnd_3.txt, rnd_4.txt, rnd_5.txt, rnd_6.txt, rnd_7.txt, rnd_8.txt, rnd_9.txt, sample1.txt, sample2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
even0.txt | WA | 17 ms | 640 KB |
even1.txt | WA | 17 ms | 640 KB |
float.txt | WA | 17 ms | 640 KB |
odd0.txt | AC | 17 ms | 640 KB |
odd1.txt | AC | 17 ms | 640 KB |
rnd_0.txt | WA | 16 ms | 640 KB |
rnd_1.txt | WA | 14 ms | 640 KB |
rnd_2.txt | WA | 15 ms | 640 KB |
rnd_3.txt | AC | 14 ms | 640 KB |
rnd_4.txt | AC | 13 ms | 512 KB |
rnd_5.txt | AC | 17 ms | 640 KB |
rnd_6.txt | AC | 14 ms | 512 KB |
rnd_7.txt | AC | 13 ms | 512 KB |
rnd_8.txt | AC | 15 ms | 640 KB |
rnd_9.txt | WA | 15 ms | 640 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |