-
Notifications
You must be signed in to change notification settings - Fork 9
/
ceil.cpp
76 lines (63 loc) · 1.61 KB
/
ceil.cpp
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
71
72
73
74
75
76
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
#define endl "\n"
#define FILEIO freopen("test1.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
#define ALL(v) v.rbegin(),v.rend()
typedef vector<LL> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef map<LL ,LL > mii;
typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second
vi vect;
LL find_ceil(int start , int end , int ele)
{
LL res=__LONG_LONG_MAX__;
while(start<=end)
{
int mid = start + (end-start)/2;
if(vect[mid]==ele){
return ele;
}
if(vect[mid]<ele)
start = mid+1;
else
{
res = vect[mid];
end = mid-1;
}
}
return res;
}
int main()
{
int n , ele;
cin>>n >>ele;
vect.resize(n);
for(int i=0;i<n;i++)
cin>>vect[i];
sort(all(vect));
cout<<find_ceil(0 , n-1 , ele)<<endl;
}