Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- int cifri[10];
- for(int i = 0; i <= 9; i++) {
- cifri[i] = 0; // sekoja cifra na pocetok se pojavila 0 pati
- }
- for(int i = 0; i < n; i++) {
- char c;
- cin >> c;
- cifri[c - '0']++;
- }
- int niza[m];
- for(int i = 0; i < m; i++) {
- cin >> niza[i];
- }
- for(int i = 0; i < m; i++) {
- int suma = 0;
- for(int j = 9; j >= 0; j--) {
- suma += cifri[j];
- if(suma >= niza[i]) {
- cout << j << " ";
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement