algorithm'''problem solve
[백준] 5525 - IOIOI(설명X)
JunHwa Park
2020. 4. 30. 18:14
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 | #include <iostream> #include <string> using namespace std; int main() { int N, M, count = 0; string S; cin >> N >> M >> S; for (int j = 0; j < M; j++) { if (S[j] == 'I') { char tmp = S[j]; int num = 1; while (S[++j] != tmp && j < M) { tmp = S[j]; num++; } j--; if (num - (2 * N + 1) >= 0) { count++; count += (num - (2 * N + 1)) / 2; } } } cout << count << "\n"; } | cs |