# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
688376 |
2023-01-27T11:22:33 Z |
Gital |
JJOOII 2 (JOI20_ho_t2) |
C++11 |
|
1 ms |
316 KB |
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
int cnt[3];
int ans;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int N,K; cin >> N >> K;
int first = 0; int last = N - 1;
string s; cin >> s;
for(int i = 0; i < N; i++) {
if(cnt[0] != K) {
if(s[i] == 'J') cnt[0]++;
else{
if(i == first) first++;
else if(i == last) last--;
else ans++;
}
}
else if(cnt[1] != K) {
if(s[i] == 'O') cnt[1]++;
else{
if(i == first) first++;
else if(i == last) last--;
else ans++;
}
}
else if(cnt[2] != K) {
if(s[i] == 'I') cnt[2]++;
else{
if(i == first) first++;
else if(i == last) last--;
else ans++;
}
}
}
for(int i = 0; i < 3; i++) {
if(cnt[i] != K) {
cout << -1;
return 0;
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |