# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
955238 | Dennis_Jason | JJOOII 2 (JOI20_ho_t2) | C++14 | 0 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define NMAX 200001
#define pb push_back
#define MOD 1000000007
#define nl '\n'
#define INF 0x3f3f3f3f
#define int long long
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
int n,k;
string s;
/// op1:delete s[0]
/// op2:delete s[s.size()-1]
/// op3:delete between (0,s.size()-1)
signed main() {
cin>>n>>k;
cin>>s;
int cnt=0;
int cntJ=0,cntO=0,cntI=0;
for(int i=0;i<s.size();++i)
{
if(s[i]!='J' && cntJ==0)
continue;
if(s[i]!='I'&& cntI==k)
break;
if(s[i]=='J')
{
if(cntJ<k)
{
cntJ++;
}
else if(cntJ==k && cntO<k)
{
cnt++;
}
else if(cntJ==k && cntO==k && cntI<k)
{
cnt++;
}
}
if(s[i]=='O')
{
if(cntJ==k && cntO<k)
{
cntO++;
}
else if(cntJ==k && cntO==k)
{
cnt++;
}
else if(cntJ<k)
{
cnt++;
}
}
if(s[i]=='I')
{
if(cntJ==k && cntO==k && cntI<k)
{
cntI++;
}
else if(cntJ<k)
{
cnt++;
}
else if(cntO<k)
cnt++;
}
}
//cout<<cntI<<" "<<cntO<<" "<<cntJ<<nl;
if(cntI!=k ||cntO!=k ||cntJ!=k)
cout<<-1;
else
cout<<cnt;
return 0;
}
컴파일 시 표준 에러 (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... |