Submission #1104256

# Submission time Handle Problem Language Result Execution time Memory
1104256 2024-10-23T10:53:13 Z zephyrion JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 512 KB
#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 += 1;
                    }
                }
            }
        }
    }
    if (ans == INT_MAX){
        cout << -1 << endl;
    }
    else{
        cout << ans;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Incorrect 1 ms 512 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Incorrect 1 ms 512 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Incorrect 1 ms 512 KB Output isn't correct
5 Halted 0 ms 0 KB -