# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
404453 | radaiosm7 | JJOOII 2 (JOI20_ho_t2) | C++98 | 12 ms | 1996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, k, f, one, two, three;
vector<int> j;
vector<int> o;
vector<int> i;
char word[200005];
int ans;
int main() {
scanf("%d%d", &n, &k);
scanf("\n%s", word);
f = strlen(word);
ans = INT_MAX;
for (f=0; f < n; ++f) {
if (word[f] == 'J') {
j.push_back(f);
}
else if (word[f] == 'O') {
o.push_back(f);
}
else {
i.push_back(f);
}
}
for (one=k-1; one < (int)j.size(); ++one) {
two = upper_bound(o.begin(), o.end(), j[one])-o.begin();
if (two+k-1 >= (int)o.size()) {
continue;
}
three = upper_bound(i.begin(), i.end(), o[two+k-1])-i.begin();
if (three+k-1 >= (int)i.size()) {
continue;
}
ans = min(ans, max(0, i[three+k-1]-j[one-k+1]+1-3*k));
}
if (ans == INT_MAX) {
printf("-1\n");
}
else {
printf("%d\n", ans);
}
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... |