https://www.acmicpc.net/problem/2455
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
|
#include <iostream>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class train_simulator
{
public:
void get_in(unsigned int passingers)
{
_passingers += passingers;
_compMaximum();
}
void get_out(unsigned int passingers)
{
_passingers -= passingers;
}
unsigned int get_maximum_passingers()
{
return _maximumPassingersPerDay;
}
private:
void _compMaximum()
{
_maximumPassingersPerDay = _maximumPassingersPerDay < _passingers ? _passingers : _maximumPassingersPerDay;
}
private:
unsigned int _passingers = 0;
unsigned int _maximumPassingersPerDay = 0;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void input(train_simulator& myTrain)
{
unsigned int passingers_in, passingers_out;
do
{
std::cin >> passingers_out >> passingers_in;
myTrain.get_out(passingers_out);
myTrain.get_in(passingers_in);
} while (passingers_in != 0);
}
void output(train_simulator& ans)
{
std::cout << ans.get_maximum_passingers();
}
int main()
{
train_simulator myTrain;
input(myTrain);
output(myTrain);
return 0;
}
|
cs |
뿌뿌~~~~칙칙폭폭칙칙폭폭칙칙폭폭칙칙폭폭
'알고리즘' 카테고리의 다른 글
백준 14890 : 경사로 (0) | 2020.07.17 |
---|---|
백준 1094 : 막대기 (0) | 2020.07.16 |
백준 14889 : 스타트와 링크 (0) | 2020.07.15 |
koi : 선물(M) (0) | 2020.07.14 |
koi : 경찰차(M) (0) | 2020.07.14 |