Submission #245184

#TimeUsernameProblemLanguageResultExecution timeMemory
245184uacoder123JJOOII 2 (JOI20_ho_t2)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); lli test=1; for(;test>0;--test) { lli n,k,ans; string s; cin>>n>>k>>s; ans=n; vi j,o,i; for(lli i1=0;i1<s.size();++i1) { if(s[i1]=='J') j.pb(i1); else if(s[i1]=='O') o.pb(i1); else i.pb(i1); } lli l=0; for(lli i1=0;i1<j.size();++i1) { lli pans=0; if(j.size()-i1>=k) pans+=j[i1+k-1]-j[i1]+1-k; else continue; l=j[i1+k-1]+1; lli it1=lower_bound(all(o),l)-o.begin(); if(o.size()-it1>=k) pans+=o[it1+k-1]-o[it1]+1-k; else continue; l=o[it1+k-1]+1; int it2=lower_bound(all(i),l)-i.begin(); if(i.size()-it2>=k) pans+=i[it2+k-1]-i[it2]+1-k; else continue; ans=min(ans,pans); } if(ans==n) cout<<"-1"<<endl; else cout<<ans<<endl; } return(0); }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(lli i1=0;i1<s.size();++i1)
                  ~~^~~~~~~~~
ho_t2.cpp:40:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(lli i1=0;i1<j.size();++i1)
                  ~~^~~~~~~~~
ho_t2.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(j.size()-i1>=k)
          ~~~~~~~~~~~^~~
ho_t2.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(o.size()-it1>=k)
          ~~~~~~~~~~~~^~~
ho_t2.cpp:55:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(i.size()-it2>=k)
          ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...