Submission #688376

#TimeUsernameProblemLanguageResultExecution timeMemory
688376GitalJJOOII 2 (JOI20_ho_t2)C++11
0 / 100
1 ms316 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n' typedef long long ll; int cnt[3]; int ans; int main() { ios::sync_with_stdio(0); cin.tie(0); int N,K; cin >> N >> K; int first = 0; int last = N - 1; string s; cin >> s; for(int i = 0; i < N; i++) { if(cnt[0] != K) { if(s[i] == 'J') cnt[0]++; else{ if(i == first) first++; else if(i == last) last--; else ans++; } } else if(cnt[1] != K) { if(s[i] == 'O') cnt[1]++; else{ if(i == first) first++; else if(i == last) last--; else ans++; } } else if(cnt[2] != K) { if(s[i] == 'I') cnt[2]++; else{ if(i == first) first++; else if(i == last) last--; else ans++; } } } for(int i = 0; i < 3; i++) { if(cnt[i] != K) { cout << -1; return 0; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...