답안 #1104258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104258 2024-10-23T10:55:51 Z zephyrion JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 336 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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -