# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
208431 |
2020-03-11T08:01:50 Z |
cstuart |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
4 ms |
376 KB |
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007ll
#define EPS 1e-9
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pl;
typedef tuple <ll,ll,ll> tl;
ll N, K, B;
vector <ll> VJ, VO, VI;
vector <ll>::iterator VJS, VJE, VOS, VOE, VIS, VIE;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> K;
for (ll i = 1; i <= N; i++) {
char ch;
cin >> ch;
if (ch == 'J') VJ.push_back(i);
else if (ch == 'O') VO.push_back(i);
else VI.push_back(i);
}
B = 1000000;
for (ll i = 0; i < (ll)VJ.size(); i++) {
VJS = VJ.begin();
if (VJ.end() - VJS <= K) continue;
VJE = VJS + K - 1;
VOS = upper_bound(VO.begin(), VO.end(), *VJE);
if (VO.end() - VOS <= K) continue;
VOE = VOS + K - 1;
VIS = upper_bound(VI.begin(), VI.end(), *VOE);
if (VI.end() - VIS <= K) continue;
VIE = VIS + K - 1;
ll C = N - (*VJS - 1) - (N - *VIE) - (3 * K);
B = min(B, C);
}
if (B == 1000000) cout << -1;
else cout << B;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |