# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023704 | 2024-07-15T05:05:46 Z | vjudge1 | JJOOII 2 (JOI20_ho_t2) | C++17 | 1 ms | 348 KB |
#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; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |