Submission #14358523


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int X, N;
set<int> p;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X >> N;
	rep(i, 0, N) {
		int x; cin >> x;
		p.insert(x);
	}

	int ans = inf, diff = inf;
	rep(y, 0, 102) if (!p.count(y)) {
		int d = abs(y - X);
		if (d < diff) ans = y, diff = d;
	}
	cout << ans << endl;
}





Submission Info

Submission Time
Task C - Forbidden List
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 300
Code Size 1660 Byte
Status AC
Exec Time 2 ms
Memory 3640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample a01.txt, a02.txt, a03.txt
All a01.txt, a02.txt, a03.txt, b04.txt, b05.txt, b06.txt, b07.txt, b08.txt, b09.txt, b10.txt, b11.txt, b12.txt, b13.txt, b14.txt, b15.txt
Case Name Status Exec Time Memory
a01.txt AC 2 ms 3640 KB
a02.txt AC 2 ms 3604 KB
a03.txt AC 2 ms 3540 KB
b04.txt AC 2 ms 3488 KB
b05.txt AC 2 ms 3484 KB
b06.txt AC 2 ms 3580 KB
b07.txt AC 2 ms 3544 KB
b08.txt AC 2 ms 3592 KB
b09.txt AC 2 ms 3540 KB
b10.txt AC 2 ms 3476 KB
b11.txt AC 2 ms 3576 KB
b12.txt AC 2 ms 3604 KB
b13.txt AC 2 ms 3616 KB
b14.txt AC 2 ms 3528 KB
b15.txt AC 2 ms 3480 KB