| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 484698 | Jarif_Rahman | JJOOII 2 (JOI20_ho_t2) | C++17 | 12 ms | 2016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int inf = 1e9;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k; str s; cin >> n >> k >> s;
vector<int> J, O, I;
for(int i = 0; i < n; i++){
if(s[i] == 'J') J.pb(i);
if(s[i] == 'O') O.pb(i);
if(s[i] == 'I') I.pb(i);
}
int ans = inf;
for(int i = k-1; i < O.size(); i++){
int cur = n;
cur-=3*k;
auto it = lower_bound(J.begin(), J.end(), O[i-k+1]);
int j = it-J.begin();
j--;
j-=k-1;
if(j < 0) continue;
cur-=J[j];
it = lower_bound(I.begin(), I.end(), O[i]);
if(it == I.end()) continue;
j = it-I.begin();
j+=k-1;
if(j >= I.size()) continue;
cur-=n-I[j]-1;
ans = min(ans, cur);
}
if(ans == inf) ans = -1;
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
