Submission #520385

#TimeUsernameProblemLanguageResultExecution timeMemory
520385aris12345678JJOOII 2 (JOI20_ho_t2)C++14
13 / 100
2053 ms808 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); string s; cin >> s; int ans = INT_MAX; for(int i = 0; i < n; i++) { if(s[i] != 'J') continue; string t = ""; int m = 0; for(int j = i; j < n; j++) { if(m < k && s[j] == 'J') t += s[j], m++; if(m >= k && m < 2*k && s[j] == 'O') t += s[j], m++; if(m >= 2*k && m < 3*k && s[j] == 'I') t += s[j], m++; if(m == 3*k) { ans = min(ans, (j-i+1)-m); // cout << i << " " << j << ": " << t << "\n"; } } } if(ans == INT_MAX) printf("-1\n"); else printf("%d\n", ans); return 0; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...