Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int niza[10];
- int n, k;
- cin>>n>>k;
- for(int i=0; i<10; i++){
- niza[i]=0;
- }
- for(int i=0; i<n; i++){
- char c;
- cin>>c;
- niza[c-'0']+=1;
- }
- for(int i=0; i<k; i++){
- int k1;
- cin>>k1;
- for(int j=9; j>=0; j--){
- if(k1>niza[j]){
- k1-=niza[j];
- }
- else{
- cout<<j<<" ";
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement