# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1023702 | vjudge1 | JJOOII 2 (JOI20_ho_t2) | C++17 | 1 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
using namespace std;
int min_operations_to_form_JOI_string(int N, int K, const string& S) {
if (K > N / 3) return -1;
int required_count = K * 3;
int count_J = 0, count_O = 0, count_I = 0;
int left = 0, right = N - 1;
while (left <= right) {
if (count_J < K && S[left] == 'J') {
count_J++;
left++;
} else if (count_I < K && S[right] == 'I') {
count_I++;
right--;
} else if (count_O < K && S[left] == 'O') {
count_O++;
left++;
} else {
left++;
right--;
}
}
int remaining_operations = 0;
if (count_J < K) remaining_operations += K - count_J;
if (count_O < K) remaining_operations += K - count_O;
if (count_I < K) remaining_operations += K - count_I;
return remaining_operations;
}
int main() {
int N, K;
string S;
cin >> N >> K >> S;
int result = min_operations_to_form_JOI_string(N, K, S);
cout << result << endl;
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... |