티스토리 뷰
728x90
문제 링크
https://www.acmicpc.net/problem/15781
헬멧과 조끼는 서로에게 영향을 주지 않는다.
따라서 헬멧 중 가장 높은 방어력을 가진 것과, 조끼 중 가장 높은 방어력을 가진 것을 골라 더해주면 된다.
정답 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int n, m; | |
int main() { | |
ios_base::sync_with_stdio(false); | |
cin.tie(0); | |
cin >> n >> m; | |
int a = -10, b = -10; | |
while (n--) { | |
int x; | |
cin >> x; | |
if (x > a) a = x; | |
} | |
while (m--) { | |
int x; | |
cin >> x; | |
if (x > b) b = x; | |
} | |
cout << a + b; | |
} |
728x90
'알고리즘 > 문제 풀이' 카테고리의 다른 글
[BOJ] 백준 12888 완벽 이진 트리 도로 네트워크 (0) | 2018.07.05 |
---|---|
[2018 IUPC] 백준 15782 Calculate! 2 (4) | 2018.06.29 |
[2018 IUPC] 백준 15780 멀티탭 충분하니? (0) | 2018.06.29 |
[BOJ] 백준 5214 환승 (3) | 2018.06.29 |
[BOJ] 백준 1008 A/B (0) | 2018.06.28 |