#include <cassert> #include <iostream> #include <string> #include <algorithm> std::string getInput() { int testsCount = 0; std::cin >> testsCount; std::string testResults; testResults.reserve(testsCount); std::cin >> testResults; return testResults; } int countScore(const std::string& testResults) { const int n = testResults.size(); const int step = n / 10; int score = 0; for (int i = 0; i < n; i += step) { const int count = std::count(testResults.begin() + i, testResults.begin() + i + step, 'N'); if (count <= 0) { score++; } } return score; } int main() { const std::string testResults = getInput(); std::cout << countScore(testResults); }
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 | #include <cassert> #include <iostream> #include <string> #include <algorithm> std::string getInput() { int testsCount = 0; std::cin >> testsCount; std::string testResults; testResults.reserve(testsCount); std::cin >> testResults; return testResults; } int countScore(const std::string& testResults) { const int n = testResults.size(); const int step = n / 10; int score = 0; for (int i = 0; i < n; i += step) { const int count = std::count(testResults.begin() + i, testResults.begin() + i + step, 'N'); if (count <= 0) { score++; } } return score; } int main() { const std::string testResults = getInput(); std::cout << countScore(testResults); } |