Task: | Prinova |
Sender: | untokarila |
Submission time: | 2019-07-29 15:31:51 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | ACCEPTED | 0.01 s | details |
#7 | ACCEPTED | 0.01 s | details |
#8 | ACCEPTED | 0.01 s | details |
#9 | ACCEPTED | 0.01 s | details |
#10 | ACCEPTED | 0.01 s | details |
Code
#include <iostream> #include <algorithm> #define F first #define S second using namespace std; int d[100]; pair<int, int> p; int main(){ int n, a, b; cin >> n; for(int i=0; i<n; i++) cin >> d[i]; cin >> a >> b; sort(d, d+n); for(int i=1; i<n; i++){ if(d[i]<a) continue; if(d[i-1]>b) continue; int dist = (d[i]-d[i-1])/2; if(d[i-1]+dist <= a){ dist = a-d[i-1]; if(!((d[i-1]+dist)&1)) dist++; } if(d[i-1]+dist >= b){ dist = b-d[i-1]; if(!((d[i-1]+dist)&1)) dist--; } if(!((d[i-1]+dist)&1)) dist++; int val = min(dist, d[i]-d[i-1]-dist); if(val > p.F) p = {val, d[i-1]+dist}; } if(!(a&1)) a++; if(!(b&1)) b--; if(a<=d[0] && d[0]-a >= p.F) p = {d[0]-a, a}; if(b>=d[n-1] && b-d[n-1] >= p.F) p = {b-d[n-1], b}; cout << p.S; return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
5
38 50 60 30 48 23 69 |
correct output |
---|
69 |
user output |
---|
69 |
Test 2
Verdict: ACCEPTED
input |
---|
5
12 10 50 24 40 9 16 |
correct output |
---|
15 |
user output |
---|
15 |
Test 3
Verdict: ACCEPTED
input |
---|
10
46 64 26 82 18 106 60 138 194 ... |
correct output |
---|
165 |
user output |
---|
167 |
Test 4
Verdict: ACCEPTED
input |
---|
20
114 48 86 180 176 66 126 194 5... |
correct output |
---|
99 |
user output |
---|
101 |
Test 5
Verdict: ACCEPTED
input |
---|
30
46 112 106 70 186 80 62 2 162 ... |
correct output |
---|
25 |
user output |
---|
25 |
Test 6
Verdict: ACCEPTED
input |
---|
50
7362 772 4354 5462 4924 5224 2... |
correct output |
---|
3953 |
user output |
---|
3953 |
Test 7
Verdict: ACCEPTED
input |
---|
67
7518 4798 5528 3806 7798 3396 ... |
correct output |
---|
6467 |
user output |
---|
6467 |
Test 8
Verdict: ACCEPTED
input |
---|
79
263044060 323471968 60083128 7... |
correct output |
---|
173959055 |
user output |
---|
173959057 |
Test 9
Verdict: ACCEPTED
input |
---|
99
412812216 39588698 618476302 2... |
correct output |
---|
2577535 |
user output |
---|
2577535 |
Test 10
Verdict: ACCEPTED
input |
---|
100
635179944 592614358 645156538 ... |
correct output |
---|
493216533 |
user output |
---|
493216533 |