Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 0 KBi |
#2 |
Incorrecto
|
0.005 s | 0 KBi |
#3 |
Incorrecto
|
0.007 s | 1 KBi |
#4 |
Incorrecto
|
0.004 s | 0 KBi |
#5 |
Incorrecto
|
0.005 s | 1 KBi |
#6 |
Incorrecto
|
0.004 s | 0 KBi |
#7 |
Incorrecto
|
0.007 s | 0 KBi |
#8 |
Incorrecto
|
0.005 s | 0 KBi |
#9 |
Incorrecto
|
0.005 s | 0 KBi |
#10 |
Incorrecto
|
0.004 s | 0 KBi |
#include <bits/stdc++.h> using namespace std; #define vi vector<int> int binarySearch2(vi &arr, int x, int l, int r) { while (l <= r) { int mid = l + (r - l) / 2; if (arr[mid] > x && arr[mid-1] <= x) return mid; if (arr[mid] <= x) l = mid + 1; else r = mid - 1; } return -1; } int main() { int n, c, x; cin >> n; vi nums(n); for (auto &x : nums) cin >> x; sort(nums.begin(), nums.end()); cin >> c; while (c--) { cin >> x; // int ans = binarySearch2(nums, x, 0, nums.size()-1); int ans = *upper_bound(nums.begin(), nums.end(), x); cout << (ans ? n - (ans - 1) : 0) << endl; } return 0; }