File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 706
706
| 27 | [ 방탈출] ( https://www.acmicpc.net/problem/15729 ) | [ cpp] ( source/15729.cpp ) | 28 | [ 세탁소 사장 동혁] ( https://www.acmicpc.net/problem/2720 ) | [ cpp] ( source/2720.cpp ) |
707
707
| 29 | [ 욱제는 도박쟁이야!!] ( https://www.acmicpc.net/problem/14655 ) | [ cpp] ( source/14655.cpp ) | 30 | [ Project Teams] ( https://www.acmicpc.net/problem/20044 ) | [ cpp] ( source/20044.cpp ) |
708
708
| 31 | [ 수강변경] ( https://www.acmicpc.net/problem/23305 ) | [ cpp] ( source/23305.cpp ) | 32 | [ 온라인 판매] ( https://www.acmicpc.net/problem/1246 ) | [ cpp] ( source/1246.cpp ) |
709
+ | 33 | [ 캠핑] ( https://www.acmicpc.net/problem/4796 ) | [ cpp] ( source/4796.cpp ) | | | |
709
710
710
711
</details >
711
712
Original file line number Diff line number Diff line change
1
+ // 4796. 캠핑
2
+ // 2022.03.12
3
+ // 그리디 알고리즘
4
+ #include < iostream>
5
+
6
+ using namespace std ;
7
+
8
+ int main ()
9
+ {
10
+ int l, p, v;
11
+ int cnt = 0 ;
12
+ while (1 )
13
+ {
14
+ cnt++;
15
+ cin >> l >> p >> v;
16
+ if (l == 0 and p == 0 and v == 0 )
17
+ {
18
+ break ;
19
+ }
20
+
21
+ int ans = 0 ;
22
+ ans += (v / p) * l;
23
+
24
+ // 잔여로 쉴수 있을때는 무조건 최대로 쉰다.
25
+ ans += v % p > l ? l : v % p;
26
+ cout << " Case " << cnt << " : " << ans << endl;
27
+ }
28
+ return 0 ;
29
+ }
You can’t perform that action at this time.
0 commit comments