답안 #217106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217106 2020-03-29T01:28:47 Z jamielim JJOOII 2 (JOI20_ho_t2) C++14
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	char str[n+5];
	scanf("%s",str);
	int joi[3];memset(joi,0,sizeof(joi));
	int ans=0;
	for(int i=0;i<n;i++){
		if(joi[0]<k){
			if(str[i]=='J'){
				joi[0]++;
			}else{
				if(joi[0]==0)continue;
				ans++;
			}
		}else if(joi[1]<k){
			if(str[i]=='O'){
				joi[1]++;
			}else{
				ans++;
			}
		}else if(joi[2]<k){
			if(str[i]=='I'){
				joi[2]++;
			}else{
				ans++;
			}
		}else break;
	}
	if(joi[0]!=k||joi[1]!=k||joi[2]!=k)printf("-1");
	else printf("%d",ans);
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
ho_t2.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",str);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -