제출 #717813

#제출 시각아이디문제언어결과실행 시간메모리
717813nninJJOOII 2 (JOI20_ho_t2)C++14
100 / 100
11 ms2012 KiB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    string s;
    cin>>n>>k>>s;
    vector<int> J, O, I;
    for(int i=0;i<n;i++) {
        if(s[i]=='J') J.push_back(i);
        else if(s[i]=='O') O.push_back(i);
        else I.push_back(i);
    }
    int sz = INT_MAX;
    for(int j=k-1;j<J.size();j++) {
        int o = upper_bound(O.begin(), O.end(), J[j])-O.begin();
        if(o+k-1>=O.size()) continue;
        o += k-1;
        int i = upper_bound(I.begin(), I.end(), O[o])-I.begin();
        if(i+k-1>=I.size()) continue;
        i += k-1;
        sz = min(sz, I[i]-J[j-k+1]+1);
    }
    if(sz==INT_MAX) {
        printf("-1");
        return 0;
    }
    printf("%d", sz-k*3);
}

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

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int j=k-1;j<J.size();j++) {
      |                   ~^~~~~~~~~
ho_t2.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         if(o+k-1>=O.size()) continue;
      |            ~~~~~^~~~~~~~~~
ho_t2.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(i+k-1>=I.size()) continue;
      |            ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...