제출 #507533

#제출 시각아이디문제언어결과실행 시간메모리
507533maco1503JJOOII 2 (JOI20_ho_t2)C++14
100 / 100
7 ms5488 KiB
#include <bits/stdc++.h> #define rpd ios_base :: sync_with_stdio(0); cin.tie(0); #define ll long long #define fs first #define sc second #define pb push_back #define mod 666013 #define NMAX 100000 + 5 #define inf LLONG_MAX using namespace std; ll n,k,mat[4][200005]; int main() { rpd; cin>>n>>k; string s; cin>>s; for(ll i=0;i<s.size();i++) { mat[0][i+1]=mat[0][i]; mat[1][i+1]=mat[1][i]; mat[2][i+1]=mat[2][i]; if(s[i]=='J'){ mat[0][i+1]++; }else if(s[i]=='O'){ mat[1][i+1]++; }else { mat[2][i+1]++; } } // for(int i=0;i<=2;i++,cout<<'\n') // for(int j=1;j<=n;j++)cout<<mat[i][j]<<' '; ll i=1,j=1,ans=inf,pos=1; for(ll l=1;l<=n;l++) { while(i<=n&&mat[0][i]-mat[0][l-1]<k){ i++; } while(j<=n&&mat[1][j]-mat[1][i-1]<k){ j++; } while(pos<=n&&mat[2][pos]-mat[2][j-1]<k){ pos++; } if(i<=n&&j<=n&&pos<=n){ ans=min(ans,pos-l+1); } } if(ans==inf){ ans=3*k-1; } ans-=3*k; cout<<ans<<'\n'; return 0; }

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

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:18:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(ll i=0;i<s.size();i++)
      |                ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...