반응형

문제 출처 :


https://www.acmicpc.net/problem/13717



알고리즘 분석 :


문제 해결에 필요한 사항

1. 구현


진화가 된 후에는 2개의 사탕을 돌려받는다. << 이 과정만 해주면 문제를 쉽게 해결 할 수 있다.






소스 코드 : 


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
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
 
using namespace std;
 
int main()
{
    int n;
    cin >> n;
 
    int ans = 0;
    string str = "";
 
    int maxval = -1;
    while (n--)
    {
        string name;
        int a, b;
        cin >> name >> a >> b;
 
        int cnt = 0;
        while (b - a >= 0)
        {
            ans++;
            b -= a;
            b += 2;
            cnt++;
        }
 
        if (maxval < cnt)
        {
            maxval = cnt;
            str = name;
        }
    }
    cout << ans << '\n' << str;
 
    return 0;
}
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus

반응형

'Applied > 알고리즘 문제풀이' 카테고리의 다른 글

[5446번] 용량 부족  (0) 2018.03.08
[1744번] 수 묶기  (0) 2018.03.08
[10545번] 뚜기뚜기메뚜기  (0) 2018.03.06
[15501번] 부당한 퍼즐  (2) 2018.03.05
[11000번] 강의실 배정  (0) 2018.02.24