문제 링크입니다: https://www.acmicpc.net/problem/3034
3034번: 앵그리 창영
첫째 줄에 던진 성냥의 개수 N과 박스의 가로 크기 W와 세로 크기 H가 주어진다. (1 ≤ N ≤ 50, 1 ≤ W, H ≤ 100) 다음 N개 줄에는 성냥의 길이가 주어진다. 길이는 1보다 크거나 같고 1000보다 작거나
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or 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> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
const int MAX = 7; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int T; | |
cin >> T; | |
for (int t = 0; t < T; t++) | |
{ | |
vector<int> v(MAX); | |
for (int i = 0; i < MAX; i++) | |
{ | |
cin >> v[i]; | |
} | |
sort(v.begin(), v.end()); | |
int sum = 0; | |
int minEven = -1; | |
for (int i = 0; i <MAX; i++) | |
{ | |
if (v[i] % 2) | |
{ | |
continue; | |
} | |
if (minEven == -1) | |
{ | |
minEven = v[i]; | |
} | |
sum += v[i]; | |
} | |
cout << sum << " " << minEven << "\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 3028번 창영마을 (0) | 2021.05.14 |
---|---|
백준 3029번 경고 (0) | 2021.05.14 |
백준 3058번 짝수를 찾아라 (0) | 2021.05.14 |
백준 6757번 팰린드롬 진법 (2) | 2021.05.13 |
백준 2997번 네 번째 수 (4) | 2021.05.12 |