forked from Zy0ung/baekjoon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
58 lines (48 loc) · 1.17 KB
/
main.cpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Authored by : tony9402
// Co-authored by : -
// Link : http://boj.kr/a30111114ee042f983774cf658e84fb9
#include<bits/stdc++.h>
using namespace std;
int info[14];
int MachineJ(int money){
int cnt = 0;
for(int i=0;i<14;i++){
if(info[i] > money) continue;
cnt = money / info[i];
money %= info[i];
}
return money + cnt * info[13];
}
int MachineS(int money){
int cnt = 0;
int downCnt = 0;
int upCnt = 0;
for(int i=1;i<14;i++){
if(info[i-1] > info[i]){
downCnt ++;
upCnt = 0;
}
else if(info[i-1] < info[i]){
downCnt = 0;
upCnt++;
}
else downCnt = upCnt = 0;
if(info[i] <= money && downCnt >= 3){
cnt += money / info[i];
money %= info[i];
}
}
return money + cnt * info[13];
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int money; cin >> money;
for(int i=0;i<14;i++) cin >> info[i];
int BNP = MachineJ(money);
int TIMING = MachineS(money);
if(BNP > TIMING)cout << "BNP";
else if(BNP < TIMING)cout << "TIMING";
else cout << "SAMESAME";
return 0;
}