Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int n, period;
- cin >> n >> period;
- int bukvi[26];
- string s;
- cin >> s;
- int res = 0;
- for(int i = 0; i < period; i++) {
- for(int j = 0; j < 26; j++) {
- bukvi[j] = (n / period);
- }
- for(int j = i; j < n; j += period) {
- bukvi[s[j] - 'A']--;
- }
- int najmal_element = 2e9;
- for(int j = 0; j < 26; j++) {
- if(najmal_element > bukvi[j]) {
- najmal_element = bukvi[j];
- }
- }
- res += najmal_element;
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement