Algorithm/백준
C++ 알고리즘 - 백준 2839 설탕 배달
마루설아
2024. 12. 31. 17:27
https://www.acmicpc.net/problem/2839
#include <iostream>
#define endl "\n"
using namespace std;
int main(void) {
// C++ Init
ios::sync_with_stdio(false);
cin.tie(NULL);
int input;
int box5, box3;
int answer;
int count;
cin >> input;
box5 = input / 5;
while (true) {
count = input - (box5 * 5);
if (count % 3 == 0) {
box3 = count / 3;
cout << box5 + box3;
break;
}
else {
box5--;
}
if (box5 == -1) {
cout << -1;
break;
}
}
}