Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 선택정렬
- 비동기호출방법
- 알고리즘
- map
- C++최적화
- stl
- 데이터애셋
- 애셋로드
- dataasset
- unorder_map
- UE_LOG
- 자료구조
- 강참조
- 람다
- 언리얼가비지컬렉터
- 구조적 바인딩
- 스마트포인터
- BFS
- tweakobjectptr
- 크리티컬섹션
- 정렬알고리즘
- moreeffectiveC++
- enumasByue
- 약참조
- 정렬
- makeweakobjectptr
- C++
- UML관련
- 델리게이트
- 프로그래머스
Archives
- Today
- Total
기억을 위한 기록들
[백준 2810: 컵홀더] - C++ 본문
2810번: 컵홀더
첫째 줄에 좌석의 수 N이 주어진다. (1 ≤ N ≤ 50) 둘째 줄에는 좌석의 정보가 주어진다.
www.acmicpc.net
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
string input;
cin >> input;
int cnt = 1; //컵홀더 1개 깔고 시작
int i = 0;
while(i < input.size())
{
if (input[i] == 'S') //싱글 의자
{
cnt++;
i++;
}
else
{
cnt++;
i += 2;
}
}
cout << min(cnt, n) << "\n";
return 0;
}
'Coding Test - cpp > Greedy' 카테고리의 다른 글
[백준 1541: 잃어버린 괄호] - C++ (0) | 2021.03.05 |
---|---|
[백준 18238: ZOAC 2] - C++ (0) | 2021.02.18 |
[백준 11047: 동전 0] - C++ (0) | 2021.02.08 |
[백준 11399: ATM] - C++ (0) | 2021.02.08 |
[백준 1343: 폴리오미노] - C++ (0) | 2021.02.04 |