Submission #954549

#TimeUsernameProblemLanguageResultExecution timeMemory
954549irmuunJJOOII 2 (JOI20_ho_t2)C++17
100 / 100
11 ms3328 KiB
#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 (stderr)

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()){
      |            ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...