Submission #203225

#TimeUsernameProblemLanguageResultExecution timeMemory
203225staniewzkiJJOOII 2 (JOI20_ho_t2)C++14
100 / 100
22 ms1792 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n, k; string str; cin >> n >> k >> str; vector<vector<int>> pos(3); vector<int> last(4, -1e9); map<char, int> id = {{'J', 0}, {'O', 1}, {'I', 2}}; int ans = 1e9; for(int i = 0; i < n; i++) { last[0] = i; int x = id[str[i]]; pos[x].emplace_back(last[x]); if(pos[x].size() >= k) last[x + 1] = pos[x][pos[x].size() - k]; ans = min(ans, i - last[3] + 1 - 3 * k); } if(ans > n) ans = -1; cout << ans << "\n"; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pos[x].size() >= k)
      ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...