# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747685 | Sami_Massah | JJOOII 2 (JOI20_ho_t2) | C++17 | 16 ms | 3556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 12, mod = 1e9 + 7, inf = 1e9 + 12 ;
long long n, k, cnt[maxn];
vector<int> locs[3];
string s;
int main(){
cin >> n >> k;
cin >> s;
cnt[1] = (s[0] == 'O');
for(int i = 1; i < n; i++)
if(s[i] == 'O')
cnt[i] = cnt[i - 1] + 1;
else
cnt[i] = cnt[i - 1];
for(int i = 0; i < n; i++)
if(s[i] == 'J')
locs[0].push_back(i);
else if(s[i] == 'O')
locs[1].push_back(i);
else
locs[2].push_back(i);
long long ans = maxn;
for(int loc = 0; loc + k - 1 < locs[0].size(); loc++){
int ne = locs[0][loc + k - 1];
int l = -1, r = locs[2].size() - k + 1, mid;
while(r - l != 1){
int mid = (l + r) / 2;
Compilation message (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... |