티스토리 뷰

728x90

문제 링크

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


헬멧과 조끼는 서로에게 영향을 주지 않는다.

따라서 헬멧 중 가장 높은 방어력을 가진 것과, 조끼 중 가장 높은 방어력을 가진 것을 골라 더해주면 된다.



정답 코드

#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;
}
view raw 15781.cpp hosted with ❤ by GitHub


728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/04   »
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
글 보관함