Advertisement
superiqbal7

Untitled

Aug 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,k,ar[1000],c=0,flag=0,count[26] = {0};
  7. char string[1000];
  8. scanf("%d %d",&n,&k);
  9. getchar();
  10. gets(string);
  11. while (string[c] != '\0')
  12. {
  13.  
  14. if (string[c] >= 'a' && string[c] <= 'z')
  15. count[string[c]-'a']++;
  16. c++;
  17. }
  18. for (c = 0; c < 26; c++)
  19. {
  20.  
  21.  
  22. if(count[c] > k && n <= 2*k)
  23. {
  24.  
  25. flag=1;
  26. }
  27. else if(count[c] > k && (n-count[c])<k && )
  28. {
  29.  
  30. flag=1;
  31. }
  32. }
  33. if(flag==0)printf("YES\n");
  34. else printf("NO\n");
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement