답안 #906209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906209 2024-01-13T16:13:41 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n, k, dem = 0;

map <char, ll> cnt;

char a[5] = {'J', 'O', 'I'};

string s;

int main(){

	ios_base::sync_with_stdio(0);
	
	cin.tie(0);
	
	cin>>n>>k>>s;
	
	ll i = 0, j = 0;
	
	n--;
	
	bool flag = false;
	
	while(i <= n){
		
		if(flag == false){
			
			while(s[i] != 'J' && i <= n){
				
				i++;
			}
			while(s[n] != 'I' && n > 0){
				
				n--;
			}
			flag = true;
		}
		else{
			
			while(cnt[a[j]] < k && i <= n){
				
				if(s[i] == a[j]) cnt[s[i]]++;
				
				else dem++;
				
				i++;
			}
			j++;
		}
//		cout<<cnt['J']<<" "<<cnt['O']<<" "<<cnt['I']<<'\n';
	}
	if(cnt['J'] == cnt['O'] && cnt['O'] == cnt['I'] && cnt['J'] == k) cout<<dem;
	
	else cout<<-1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -