Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
71 lines (65 loc) · 1.41 KB

File metadata and controls

71 lines (65 loc) · 1.41 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <bits/stdc++.h>
#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);
using namespace std;
inline int mod(int n, int m) {
int ret = n % m;
if (ret < 0) ret += m;
return ret;
}
int gcd(int a, int b) {
if (a == 0)
return b;
else
return gcd(b % a, a);
}
void solution() {
int x, n;
cin >> x >> n;
int best = 1000000000;
int ans = 10000000;
set<int> s;
for (int i = 0; i < n; i++) {
int k;
cin >> k;
s.insert(k);
}
for (int i = x - 100; i <= x + 100; i++) {
if (abs(x - i) < best || (abs(x - i) == best && ans > i)) {
if (s.count(i)) continue;
ans = i;
best = abs(x - i);
}
}
cout << ans << endl;
}
int32_t main() {
DESYNC;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int t = 1;
#ifdef MULTIPLE_TEST_CASE
cin >> t;
#endif
while (t--) solution();
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.