From 7d967c99e8d72cabf27b36cbb712805199df7381 Mon Sep 17 00:00:00 2001 From: AdelRizq <40351413+AdelRizq@users.noreply.github.com> Date: Wed, 16 Oct 2019 21:58:26 +0200 Subject: [PATCH] make it faster static is faster even if by some ms --- Binary Search/706B - Interesting drink.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Binary Search/706B - Interesting drink.cpp b/Binary Search/706B - Interesting drink.cpp index 7e29692..28849ff 100644 --- a/Binary Search/706B - Interesting drink.cpp +++ b/Binary Search/706B - Interesting drink.cpp @@ -55,17 +55,21 @@ typedef long long int ll; //freopen("output.txt","w",stdout); using namespace std; + +const int MAXN = 1e5 + 5; +int arr[MAXN]; + int main() { - int n; + int n, q, temp; cin >> n; - vector Arr(n); + //vector Arr(n); for (int i = 0; i < n; i++) - cin >> Arr[i]; - sort(Arr.begin(), Arr.end()); - int q , Temp; + cin >> arr[i]; + sort(arr, arr + n); + cin >> q; for (int i = 0; i < q; i++) { - cin >> Temp; - cout << (upper_bound(Arr.begin(), Arr.end(), Temp)-Arr.begin()) << endl; + cin >> temp; + cout << upper_bound(arr, arr + n, temp) - arr << endl; } }