2839_설탕 배달

bgy·2021년 12월 30일
0

백준

목록 보기
7/21
#include <iostream> 

using namespace std;


int main() {
	int n;
	cin >> n;
	int bag5;
	bag5 = n / 5;
	int res = n % 5;
	if (res % 3 == 0) {
		cout << bag5 + res / 3 ;
		return 0;
	}

	for (bag5; bag5 >= 0; bag5--) {
		if ((n - bag5 * 5) % 3 == 0) {
			cout << bag5 + (n - bag5 * 5) / 3 ;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

0개의 댓글