※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 9443번 문제인 Arrangement of Contest이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/9443
9443번: Arrangement of Contest
Little Dmitry and little Petr want to arrange a contest. Their little friends submitted several task proposals and now Dmitry and Petr want to select some of them for the contest. As they are just little boys, they cannot estimate quality of tasks, but the
www.acmicpc.net
먼저, 주어지는 각 문제의 제목의 첫글자들을 저장해둔 배열을 하나 만들자.
이제 'A'부터 차례대로 위의 배열을 살펴보면서 대회에 넣을 수 있는 문제의 수의 최댓값을 구해 문제를 해결하자.
아래는 제출한 소스코드이다.
#include <iostream>
#include <string>
using namespace std;
int N;
bool visited[128];
int idx = 'A';
int ans;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
while (N--) {
string s; cin >> s;
visited[s[0]] = 1;
}
while (visited[idx]) ans++, idx++;
cout << ans;
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 15001 // C++] Frog Leaps (0) | 2022.12.26 |
---|---|
[BOJ 26773 // C++] Deski kontratakują (0) | 2022.12.26 |
[BOJ 17598 // C++] Animal King Election (0) | 2022.12.26 |
[BOJ 26645 // C++] 성장의 비약 선택권 (0) | 2022.12.26 |
[BOJ 26009 // C++] 험난한 등굣길 (0) | 2022.12.26 |