제출 #413567

#제출 시각아이디문제언어결과실행 시간메모리
413567OzyJJOOII 2 (JOI20_ho_t2)C++17
13 / 100
2080 ms716 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debugsl(a) cout << #a << " = " << a << ", " #define debug(a) cout << #a << " = " << a << endl lli n,k,ini,fin,res,mitad,letra,cant; char arr[200002],letras[3]; bool checa(lli m) { rep(i,1,n-m+1) { letra = 0; cant = 0; rep(j,0,m-1) { if (arr[j+i] == letras[letra]){ cant++; if (cant == k) {letra++; cant=0;} } if (letra == 3) return true; } } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; rep(i,1,n) cin >> arr[i]; ini = k*3; fin = n; res = -1; letras[0] = 'J'; letras[1] = 'O'; letras[2] = 'I'; while (ini <= fin) { mitad = (ini+fin) / 2; if (checa(mitad)){ res = mitad - (k*3); fin = mitad-1; } else ini = mitad + 1; } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...