-
-
Save fredbr/f2c4f7f766136386da712e4c359f94ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# solucao de zeze deaugusto | |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
#include <cstdlib> | |
using namespace std; | |
int main(void) | |
{ | |
long long tama, tamb; | |
cin >> tama; | |
cin >> tamb; | |
vector<long long> a; | |
vector<long long> b; | |
long long i, in; | |
for(i=0; i < tama; i++) // lendo os numeros do vetor a | |
{ | |
cin >> in; | |
a.push_back(in); | |
} | |
for(i=0; i < tamb; i++) // lendo os numeros do vetor b | |
{ | |
cin >> in; | |
b.push_back(in); | |
} | |
sort(a.begin(), a.end()); // ordenando para fazer busca binária | |
for(i=0; i < b.size(); i++) | |
{ | |
cout << upper_bound(a.begin(), a.end(), b[i]) - a.begin() << endl; | |
/*printando a posição relativa do limitante superior, que vai me dar o numero de elementos menor ou igual a b[i]*/ | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment