-
Educational Codeforces Round 26 - A. Text Volume코드포스(CodeForce) 2018. 8. 17. 18:07반응형
1. 문제
2. 알고리즘
키워드 - 구현
* 문제 접근
주어진 Text 에서 Volume 을 찾음
Volume 에 조건은 대문자
공백 문자를 기준으로 문자열을 분리하고
분리된 문자열에서 가장 많은 Volume 의 개수를 출력
3. 코드
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#include <iostream>#include <vector>#include <algorithm>#include <functional>#include <string>#include <sstream>using namespace std;vector<string> split(string str) {string tmp;vector<string> ret;for (int i = 0; i < str.size(); ++i) {if (str[i] == ' ') {ret.push_back(tmp);tmp.clear();} else {tmp.push_back(str[i]);}}return ret;}int main() {int n; cin >> n;string sentence;getline(cin, sentence);getline(cin, sentence);int sol = 0;int count = 0;for (int i=0; i<=n; i++){char ch = sentence[i];if (ch == ' ' || i == n) {sol = max(sol, count);count = 0;}if (ch >= 'A'&& ch <='Z') {count++;}}cout << sol << endl;return 0;}cs 반응형'코드포스(CodeForce)' 카테고리의 다른 글
Educational Codeforces Round 28 - A. Curriculum Vitae (0) 2018.08.17 Educational Codeforces Round 27 - A. Chess Tourney (0) 2018.08.17 Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round) - A - Friends Meeting (0) 2018.08.17 Codeforces Round #464 (Div. 2) - A - Love Triangle (0) 2018.08.17 Educational Codeforces Round 39 (Rated for Div. 2) - A. Partition (0) 2018.08.17