제출 #1234114

#제출 시각아이디문제언어결과실행 시간메모리
1234114marJJOOII 2 (JOI20_ho_t2)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e18;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int res = inf;

    vector<int> j, o, i;
    
    for (int x = 0; x < n; ++x) {
        char ch = s[x];
        if (ch == 'j') j.push_back(x);
        else if (ch == 'o') o.push_back(x);
        else i.push_back(x);

        if ((int)i.size() < k) continue;

        int p = i.back();
        int q = i[(int)i.size() - k];
        int r = lower_bound(o.begin(), o.end(), q) - o.begin() - k;
        if (r < 0) continue;

        q = o[r];
        r = lower_bound(j.begin(), j.end(), q) - j.begin() - k;
        if (r < 0) continue;

        q = j[r];
        res = min(res, p - q + 1 - 3 * k);
    }

    if(res==inf) cout<<"-1\n";
    else cout<<res<<endl;
    
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

ho_t2.cpp:3:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    3 | const int inf = 1e18;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...