| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 273017 | ChrisT | JJOOII 2 (JOI20_ho_t2) | C++17 | 31 ms | 2048 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
char s[200'005];
int main() {
int n,k;
scanf ("%d %d",&n,&k);
scanf ("%s",s+1);
vector<int> js,os,is;
for (int i = 1; i <= n; i++) {
if (s[i] == 'J') js.push_back(i);
else if (s[i] == 'O') os.push_back(i);
else is.push_back(i);
}
int ret = 1e9;
for (int i = 1; i <= n; i++) {
int needJ = lower_bound(js.begin(),js.end(),i) - js.begin();
needJ += k-1;
if (needJ < (int)js.size()) {
int pos = js[needJ];
int needO = lower_bound(os.begin(),os.end(),pos) - os.begin();
needO += k-1;
if (needO < (int)os.size()) {
pos = os[needO];
int needI = lower_bound(is.begin(),is.end(),pos) - is.begin();
needI += k-1;
if (needI < (int)is.size()) {
pos = is[needI];
ret = min(ret,n - (i-1) - (n-pos) - k*3);
}
}
}
}
printf ("%d\n",ret<1e9?ret:-1);
return 0;
}
컴파일 시 표준 에러 (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... | ||||
