Skip to content

Commit

Permalink
전자레인지
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Apr 17, 2022
1 parent c677140 commit 22a05de
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions greedy_algorithm/10162.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
using namespace std;
int btn[3] = { 300,60,10 };
int btnCount[3];

int main() {
int T, index = 0;
cin >> T;
while (T > 0) {
if (btn[index] <= T) {
T -= btn[index];
btnCount[index]++;
}
else {
index++;
if (index > 2) {
cout << -1 << endl;
return 0;
}
}
}
for (int i = 0; i < 3; i++) {
cout << btnCount[i] << " ";
}
}

0 comments on commit 22a05de

Please sign in to comment.