답안 #987283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987283 2024-05-22T13:43:17 Z aykhn JJOOII 2 (JOI20_ho_t2) C++17
100 / 100
10 ms 3296 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define inf 0x3F3F3F3F
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, K;
    cin >> n >> K;
    string s;
    cin >> s;
    vector<int> v[3];
    for (int i = 0; i < n; i++) v[(s[i] == 'O') + (s[i] == 'I') * 2].push_back(i);
    int ans = inf;
    for (int i = 0; i + K <= v[0].size(); i++)
    {
        auto it = lower_bound(v[1].begin(), v[1].end(), v[0][i + K - 1]);
        if (it == v[1].end()) break;
        int j = it - v[1].begin();
        if (j + K > v[1].size()) break;
        it = lower_bound(v[2].begin(), v[2].end(), v[1][j + K - 1]);
        if (it == v[2].end()) break;
        int k = it - v[2].begin();
        if (k + K > v[2].size()) break;
        ans = min(ans, (v[2][k + K - 1] - v[0][i] + 1) - 3 * K);
    }
    cout << (ans >= inf ? -1 : ans) << '\n';
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:19:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i + K <= v[0].size(); i++)
      |                     ~~~~~~^~~~~~~~~~~~~~
ho_t2.cpp:24:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if (j + K > v[1].size()) break;
      |             ~~~~~~^~~~~~~~~~~~~
ho_t2.cpp:28:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if (k + K > v[2].size()) break;
      |             ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 544 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 544 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 7 ms 2508 KB Output is correct
37 Correct 9 ms 3028 KB Output is correct
38 Correct 10 ms 2876 KB Output is correct
39 Correct 7 ms 2980 KB Output is correct
40 Correct 4 ms 3024 KB Output is correct
41 Correct 6 ms 3028 KB Output is correct
42 Correct 9 ms 3028 KB Output is correct
43 Correct 2 ms 1968 KB Output is correct
44 Correct 2 ms 2008 KB Output is correct
45 Correct 3 ms 2968 KB Output is correct
46 Correct 3 ms 2968 KB Output is correct
47 Correct 3 ms 3024 KB Output is correct
48 Correct 4 ms 3000 KB Output is correct
49 Correct 3 ms 1960 KB Output is correct
50 Correct 4 ms 3000 KB Output is correct
51 Correct 3 ms 3028 KB Output is correct
52 Correct 2 ms 2504 KB Output is correct
53 Correct 3 ms 2896 KB Output is correct
54 Correct 5 ms 3296 KB Output is correct
55 Correct 4 ms 3296 KB Output is correct
56 Correct 3 ms 3296 KB Output is correct