일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- JanusWebRTCServer
- 달인막창
- 오블완
- Spring Batch
- terminal
- kotlin
- table not found
- 헥사고날아키텍처 #육각형아키텍처 #유스케이스
- PersistenceContext
- 티스토리챌린지
- taint
- k8s #kubernetes #쿠버네티스
- 개성국밥
- 코루틴 컨텍스트
- tolerated
- 자원부족
- 깡돼후
- vfr video
- 겨울 부산
- JanusWebRTC
- preemption #
- JanusGateway
- mp4fpsmod
- Value too long for column
- pytest
- PytestPluginManager
- VARCHAR (1)
- 코루틴 빌더
- python
- JanusWebRTCGateway
너와 나의 스토리
(BOJ) 16987 계란으로 계란치기 본문
문제: https://www.acmicpc.net/problem/16987
소스 코드:
#include <iostream> #include <queue> #include <vector> #include <string> #include <string.h> #include <tuple> #include <algorithm> #define inf 987654321 using namespace std; typedef pair<int, int> P; int n,res; vector<P> v; void func(int cur,int cnt) { if (cur == n) { res = max(res, cnt); return; } if (v[cur].first<=0) return func(cur + 1, cnt); // 현재 쥔 계란이 깨졌으면 다음 계란으로 넘어감 for (int i = 0; i < n; i++) { if (cur==i||v[i].first<=0) continue; // 깰 계란이 현재 쥐고 있는 계란이거나 깨진 계란이면 패스 v[cur].first -= v[i].second; v[i].first -= v[cur].second; // 부딪친 계란들은 내구력 감소 int t = 0; if (v[cur].first<= 0) { // 쥐고 있는 계란이 깨지면 t++; } if (v[i].first<=0) { // 부딪힌 계란이 깨지면 t++; } func(cur + 1, cnt + t); v[cur].first += v[i].second; // 초기화 v[i].first += v[cur].second; } res = max(res, cnt); } int main() { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; v.push_back({ a,b }); } func(0, 0); cout << res<<'\n';
return 0; } |
'Algorithm > 기타' 카테고리의 다른 글
(BOJ) 11055 가장 큰 증가 부분 수열 (0) | 2019.03.13 |
---|---|
(BOJ) 16988 Baaaaaaaaaduk2 (Easy) (0) | 2019.03.07 |
(BOJ) 2800 괄호 제거 (1) | 2019.03.06 |
(BOJ) 10815 숫자 카드 (0) | 2019.02.26 |
(BOJ) 13460 구슬 탈출 2 (0) | 2019.02.24 |