| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 553402 | Hanksburger | JJOOII 2 (JOI20_ho_t2) | C++17 | 15 ms | 1636 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;
vector<int> J, O, I;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k, ans=1e9;
cin >> n >> k;
for (int i=1; i<=n; i++)
{
char x;
cin >> x;
if (x=='J')
J.push_back(i);
else if (x=='O')
O.push_back(i);
else
I.push_back(i);
}
for (int i=0; i<=O.size()-k; i++)
{
int index=lower_bound(J.begin(), J.end(), O[i])-J.begin()-k;
int jndex=lower_bound(I.begin(), I.end(), O[i+k-1])-I.begin()+k-1;
if (index>=0 && jndex<I.size())
ans=min(ans, I[jndex]-J[index]+1-k*3);
}
if (ans==1e9)
cout << -1;
else
cout << ans;
return 0;
}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... | ||||
