-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomB_1124.cpp
More file actions
67 lines (54 loc) · 1.14 KB
/
comB_1124.cpp
File metadata and controls
67 lines (54 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <string>
int isVowel(char c) // 2021136089 À̰ü¿ì
{
int judge = 0;
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
judge = 1;
return judge;
}
int solve(const std::string word, int checking_length)
{
int max{0};
int cnt{0};
int i;
std::string s;
for (i = 0; i < checking_length; ++i)
{
if (isVowel(word[i]))
++cnt;
}
max = cnt;
for (int j = i; j < word.length(); j++)
{
cnt -= isVowel(word[j - checking_length]);
cnt += isVowel(word[j]);
if (max < cnt)
max = cnt;
}
return max;
}
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T;
std::cin >> T;
std::cin.ignore();
std::string word_arr[1000];
int l;
int result[1000];
for (int t{0}; t < T; ++t)
{
getline(std::cin, word_arr[t]);
std::cin >> l;
std::cin.ignore();
result[t] = solve(word_arr[t], l);
}
for (int t{0}; t < T; ++t)
{
std::cout << result[t] << '\n';
}
return 0;
}