답안 #954549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954549 2024-03-28T06:38:25 Z irmuun JJOOII 2 (JOI20_ho_t2) C++17
100 / 100
11 ms 3328 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<ll>v[3];
    for(ll i=0;i<n;i++){
        if(s[i]=='J') v[0].pb(i);
        if(s[i]=='O') v[1].pb(i);
        if(s[i]=='I') v[2].pb(i);
    }
    ll ans=1e9;
    for(ll i=k-1;i<v[0].size();i++){
        ll l=v[0][i-k+1];
        ll y=upper_bound(all(v[1]),v[0][i])-v[1].begin();
        if(y+k-1>=v[1].size()){
            continue;
        }
        y=v[1][y+k-1];
        y=upper_bound(all(v[2]),y)-v[2].begin();
        if(y+k-1>=v[2].size()){
            continue;
        }
        y=v[2][y+k-1];
        ans=min(ans,(n-3*k)-(l+(n-y-1)));
    }
    if(ans==1e9) ans=-1;
    cout<<ans;
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:25:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(ll i=k-1;i<v[0].size();i++){
      |                  ~^~~~~~~~~~~~
ho_t2.cpp:28:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if(y+k-1>=v[1].size()){
      |            ~~~~~^~~~~~~~~~~~~
ho_t2.cpp:33:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(y+k-1>=v[2].size()){
      |            ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 368 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 1 ms 360 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 0 ms 360 KB Output is correct
30 Correct 1 ms 360 KB Output is correct
31 Correct 1 ms 360 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
33 Correct 1 ms 656 KB Output is correct
34 Correct 0 ms 356 KB Output is correct
35 Correct 0 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 368 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 1 ms 360 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 0 ms 360 KB Output is correct
30 Correct 1 ms 360 KB Output is correct
31 Correct 1 ms 360 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
33 Correct 1 ms 656 KB Output is correct
34 Correct 0 ms 356 KB Output is correct
35 Correct 0 ms 360 KB Output is correct
36 Correct 9 ms 2520 KB Output is correct
37 Correct 11 ms 3040 KB Output is correct
38 Correct 10 ms 3008 KB Output is correct
39 Correct 10 ms 2996 KB Output is correct
40 Correct 7 ms 3148 KB Output is correct
41 Correct 8 ms 3028 KB Output is correct
42 Correct 9 ms 3012 KB Output is correct
43 Correct 5 ms 1968 KB Output is correct
44 Correct 5 ms 2240 KB Output is correct
45 Correct 7 ms 2968 KB Output is correct
46 Correct 6 ms 2956 KB Output is correct
47 Correct 7 ms 3028 KB Output is correct
48 Correct 7 ms 3016 KB Output is correct
49 Correct 4 ms 2004 KB Output is correct
50 Correct 7 ms 3000 KB Output is correct
51 Correct 7 ms 3180 KB Output is correct
52 Correct 4 ms 2364 KB Output is correct
53 Correct 4 ms 2896 KB Output is correct
54 Correct 4 ms 3328 KB Output is correct
55 Correct 3 ms 3292 KB Output is correct
56 Correct 3 ms 3296 KB Output is correct