그럴듯한 개발 블로그
백준 20310 타노스 c++
<algorithm>/백준 2023. 10. 24. 01:52

https://www.acmicpc.net/problem/20310 20310번: 타노스 어느 날, 타노스는 0과 1로 이루어진 문자열 $S$를 보았다. 신기하게도, $S$가 포함하는 0의 개수와 $S$가 포함하는 1의 개수는 모두 짝수라고 한다. 갑자기 심술이 난 타노스는 $S$를 구성하는 문자 www.acmicpc.net 아놔 중간에 연속된 사전적으로 제일 빠른 문자열 찾는줄알고 시간 낭비 오지게 했다. 그냥 말 그대로 뽑는거다 연속된거 아님 #include #include using namespacestd; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); string s; cin >> s; int half_zero_cnt, half_one_..

백준 1911 흙길 보수하기 c++
<algorithm>/백준 2023. 10. 14. 16:16

https://www.acmicpc.net/problem/1911 1911번: 흙길 보수하기 어젯밤 겨울 캠프 장소에서 월드 본원까지 이어지는, 흙으로 된 비밀길 위에 폭우가 내려서 N(1 ≤ N ≤ 10,000)개의 물웅덩이가 생겼다. 월드학원은 물웅덩이를 덮을 수 있는 길이가 L(1 ≤ L ≤ 1,000 www.acmicpc.net 이미 막힌 웅덩이일 경우만 생각해주면 어렵지 않은 문제이다. #include #include #include #include using namespacestd; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int M, woodLen, res = 0; vector v; cin >> M >> woodLen; for..

백준 1459 걷기 c++
<algorithm>/백준 2023. 10. 12. 16:13

https://www.acmicpc.net/problem/1459 1459번: 걷기 세준이는 학교에서 집으로 가려고 한다. 도시의 크기는 무한대이고, 도시의 세로 도로는 모든 정수 x좌표마다 있고, 가로 도로는 모든 정수 y좌표마다 있다. 세준이는 현재 (0, 0)에 있다. 그리고 ( www.acmicpc.net 어디서 비슷한 문제 풀었던거 같은데 아마 프로그래머스인가보다. #include #include #include #include using namespacestd; long long X, Y, line, cross, res = 0; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin >> X >> Y >> line >> cross; i..

백준 2879 코딩은 예쁘게 c++
<algorithm>/백준 2023. 10. 9. 17:08

https://www.acmicpc.net/problem/2879 2879번: 코딩은 예쁘게 첫째 줄에 줄의 개수 N(1 ≤ N ≤ 1,000)이 주어진다. 둘째 줄에는 현재 줄에 있는 탭의 개수가 주어지며, 1번째 줄부터 순서대로 주어진다. 탭의 개수는 0보다 크거나 같고, 80보다 작거나 같은 정수 www.acmicpc.net start부터 drag까지 1씩 뺐을때, 더했을때 비교해서 매 순간 제일 효율적인 상황으로 간다. #include // 실패코드 #include #include #include #include #include #include #include using namespacestd; vector src, dst; int res = 0, num; bool isOk() { for (int..

백준 1026 보물 c++
<algorithm>/백준 2023. 10. 5. 13:34

https://www.acmicpc.net/problem/1026 1026번: 보물 첫째 줄에 N이 주어진다. 둘째 줄에는 A에 있는 N개의 수가 순서대로 주어지고, 셋째 줄에는 B에 있는 수가 순서대로 주어진다. N은 50보다 작거나 같은 자연수이고, A와 B의 각 원소는 100보다 작거 www.acmicpc.net 정렬 기본 문제다. 역순으로 정렬하려면 algorithm::sort의 세번째 인자로 greater함수를 주면 된다. greater 이렇게 자료형을 명시해 줘야 한다 템플릿함수이기 때문. #include #include #include #include #include #include #include #include using namespacestd; intmain() { ios::sync_w..

백준 2217 로프 c++
<algorithm>/백준 2023. 10. 5. 13:18

https://www.acmicpc.net/problem/2217 2217번: 로프 N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하 www.acmicpc.net 정렬그리디~ #include #include #include #include #include #include #include #include using namespacestd; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int num, res = 0; cin >> num; vector rope; for (int i = 0; ..