Submission #906209

#TimeUsernameProblemLanguageResultExecution timeMemory
906209vjudge1JJOOII 2 (JOI20_ho_t2)C++17
0 / 100
1 ms348 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...