문제 : https://www.acmicpc.net/problem/2875


(여2, 남1)로 최대한 만들 수 있는 팀 수를 체크하고, 팀을 최대한 만든 상태에서 팀을 하나씩 줄여가며 인턴쉽을 보낸다.

#include<iostream>

using namespace std;

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int m, n, k, q;
	cin >> m >> n >> k;
	for (q = 0; ; q++) {
		if (2 * q > m || q > n)
			break;
	}
	q--;
	while (1) {
		if (m - 2 * q + n - q >= k)
			break;
		q--;
	}
	cout << q;
}

 

'Problem Solving > BOJ' 카테고리의 다른 글

[BOJ] 1759 - 암호 만들기  (0) 2019.09.24
[BOJ] 1644 - Sum of Consecutive Prime  (0) 2019.09.24
[BOJ] 1212 - 8진수 2진수  (0) 2019.09.23
[BOJ] 4355 - Relatives  (2) 2019.09.23
[BOJ] 14889 - 스타트와 링크  (0) 2019.09.21

+ Recent posts