| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 734901 | rahidilbayramli | JJOOII 2 (JOI20_ho_t2) | C++17 | 14 ms | 2000 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>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define vl vector<ll>
#define sl set<ll>
#define pb push_back
#define all(v) v.begin(), v.end()
#define f first
#define s second
#define ld long double
using namespace std;
int main()
{
int n, i, j, k, sz = INT_MAX, o;
string s;
cin >> n >> k;
cin >> s;
vector<int>J, O, I;
for(i = 0; i < n; i++)
{
if(s[i] == 'J') J.pb(i);
else if(s[i] == 'O') O.pb(i);
else I.pb(i);
}
for(j = k - 1; j < J.size(); j++)
{
o = upper_bound(all(O), J[j]) - O.begin();
if(o + k - 1 >= O.size()) continue;
o += (k - 1);
i = upper_bound(all(I), O[o]) - I.begin();
if(i + k - 1 >= I.size()) continue;
i += (k - 1);
sz = min(sz, I[i] - J[j-k+1]+1);
}
if(sz == INT_MAX) cout << "-1\n";
else cout << sz - k * 3 << "\n";
}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... | ||||
