๐Ÿ• Baaaaaarking/0x02๊ฐ• - ๊ธฐ์ดˆ ์ฝ”๋“œ ์ž‘์„ฑ ์š”๋ น II

[BOJ][C++] ๋ฐฑ์ค€ 2576๋ฒˆ: ํ™€์ˆ˜

์„ ๋‹ฌ 2023. 5. 11. 23:51
๋ฐ˜์‘ํ˜•

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

 

2576๋ฒˆ: ํ™€์ˆ˜

7๊ฐœ์˜ ์ž์—ฐ์ˆ˜๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ, ์ด๋“ค ์ค‘ ํ™€์ˆ˜์ธ ์ž์—ฐ์ˆ˜๋“ค์„ ๋ชจ๋‘ ๊ณจ๋ผ ๊ทธ ํ•ฉ์„ ๊ตฌํ•˜๊ณ , ๊ณ ๋ฅธ ํ™€์ˆ˜๋“ค ์ค‘ ์ตœ์†Ÿ๊ฐ’์„ ์ฐพ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 7๊ฐœ์˜ ์ž์—ฐ์ˆ˜ 12, 77, 38, 41, 53, 92, 85๊ฐ€ ์ฃผ์–ด์ง€

www.acmicpc.net

 

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, sum=0, m=100;
    for(int i=0; i<7; i++) {
        cin >> n;
        if(n%2 == 1) {
            m = min(m, n);
            sum += n;
        }
    }
    
    if(sum == 0) {
        cout << -1;
    } else {
        cout << sum << "\n" << m;
    }
    
    return 0;
}
๋ฐ˜์‘ํ˜•