| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1343217 | maxied | JJOOII 2 (JOI20_ho_t2) | C++20 | 2094 ms | 720 KiB |
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
string s;
cin >> s;
int ans = INT_MAX;
bool ok = false;
for (int i = 0; i < n; i++){
if (s[i] == 'J'){
// start the joi here
int need = k - 1;
int waste = 0;
int j = i + 1;
while (j < n && need){
need -= (s[j] == 'J');
waste += (s[j] != 'J');
j++;
}
if (need){
continue;
}
need = k;
while (j < n && need){
need -= (s[j] == 'O');
waste += (s[j] != 'O');
j++;
}
if (need){
continue;
}
need = k;
while (j < n && need){
need -= (s[j] == 'I');
waste += (s[j] != 'I');
j++;
}
if (need){
continue;
}
ok = true;
ans = min(ans, waste);
}
}
if (!ok){
cout << "-1" << '\n';
}
else{
cout << ans << '\n';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
