제출 #1104259

#제출 시각아이디문제언어결과실행 시간메모리
1104259zephyrionJJOOII 2 (JOI20_ho_t2)C++17
13 / 100
2093 ms964 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n, k; cin >> n >> k; string s1; cin >> s1; string s2 = ""; for (int i = 0; i < k; i++){ s2 += 'J'; } for (int i = 0; i < k; i++){ s2 += 'O'; } for (int i = 0; i < k; i++){ s2 += 'I'; } int ans = INT_MAX; for (int i = 0; i <= n; i++){ if (s1[i] != 'J'){ continue; } else{ int tmp = 0; int p = 0; for (int j = i; j <= n; j++){ if (p == 3 * k){ ans = min(ans, tmp); break; } else{ if (s1[j] == s2[p]){ p++; } else{ tmp++; } } } } } if (ans == INT_MAX){ cout << -1 << endl; } else{ cout << ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...