답안 #781532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781532 2023-07-13T07:42:01 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
100 / 100
9 ms 2132 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 

#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,a[li],k,flag,t;
int cev;
string s;
vector<int> v[3];

inline int in(){
	int x;
	scanf("%d",&x);
	return x;
}

int main(void){
	fio();
	cin>>t>>k>>s;
	n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='J')v[0].pb(i);
		if(s[i]=='O')v[1].pb(i);
		if(s[i]=='I')v[2].pb(i);
	}
	int siz=v[0].size();
	cev=n+1;
	for(int i=0;i<siz;i++){
		int at=i+k-1;
		if(at>=siz)break;
		int tut=v[0][at];
		int ind=upper_bound(v[1].begin(),v[1].end(),tut)-v[1].begin();
		ind+=k-1;
		if(ind>=(int)v[1].size()){break;}
		tut=v[1][ind];
		ind=upper_bound(v[2].begin(),v[2].end(),tut)-v[2].begin();
		ind+=k-1;
		if(ind>=(int)v[2].size())break;
		cev=min(cev,v[2][ind]-v[0][i]+1-3*k);
	}
	if(cev==n+1)cev=-1;
	cout<<cev<<endl;
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 328 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 328 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 8 ms 1704 KB Output is correct
37 Correct 9 ms 1856 KB Output is correct
38 Correct 9 ms 1908 KB Output is correct
39 Correct 7 ms 1988 KB Output is correct
40 Correct 4 ms 2016 KB Output is correct
41 Correct 7 ms 1948 KB Output is correct
42 Correct 8 ms 1812 KB Output is correct
43 Correct 3 ms 1360 KB Output is correct
44 Correct 3 ms 1416 KB Output is correct
45 Correct 3 ms 2008 KB Output is correct
46 Correct 3 ms 2024 KB Output is correct
47 Correct 3 ms 2132 KB Output is correct
48 Correct 4 ms 2032 KB Output is correct
49 Correct 3 ms 1336 KB Output is correct
50 Correct 3 ms 2020 KB Output is correct
51 Correct 4 ms 2016 KB Output is correct
52 Correct 3 ms 1496 KB Output is correct
53 Correct 4 ms 1724 KB Output is correct
54 Correct 5 ms 2016 KB Output is correct
55 Correct 3 ms 2012 KB Output is correct
56 Correct 2 ms 2012 KB Output is correct