#include <bits/stdc++.h> using namespace std; typedef int ll; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; ll wielkoscGrup = n / 10; ll ans = 0; ll witch = 1; bool passed = true; for (ll i = 0; i < n; i++) { char c; cin >> c; if (c == 'N') { passed = false; } if (witch == wielkoscGrup) { if (passed) { ans++; } witch = 1; passed = true; } else { witch++; } } cout << ans << endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <bits/stdc++.h> using namespace std; typedef int ll; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; ll wielkoscGrup = n / 10; ll ans = 0; ll witch = 1; bool passed = true; for (ll i = 0; i < n; i++) { char c; cin >> c; if (c == 'N') { passed = false; } if (witch == wielkoscGrup) { if (passed) { ans++; } witch = 1; passed = true; } else { witch++; } } cout << ans << endl; return 0; } |