https://www.acmicpc.net/problem/5054
5054번: 주차의 신
첫째 줄에 테스트 케이스의 개수 t가 주어진다. (1 ≤ t ≤ 100) 모든 테스트 케이스는 두 줄로 이루어져 있다. 첫째 줄에는 선영이가 방문할 상점의 수 n이 주어지며 (1 ≤ n ≤ 20), 둘째 줄에는 상점
www.acmicpc.net
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
int main() {
int testCase, shop, temp;
cin >> testCase;
for (int i = 0; i < testCase; i++) {
cin >> shop;
vector<int> v;
for (int j = 0; j < shop;j++) {
cin >> temp;
v.push_back(temp);
}
sort(v.begin(), v.end());
cout << (v[shop-1] - v[0]) * 2 << endl;
}
}
도저히 문제 이해가 되지않아 문제 해결 방법은 구글링 해서 푼 문제,,,
'자기개발👨💻 > 코딩 알고리즘' 카테고리의 다른 글
[C++] 백준 1448 삼각형 만들기 (0) | 2022.02.28 |
---|---|
[C++] 백준 2309 일곱 난쟁이 (0) | 2022.02.27 |
[python] 프로그래머스 실패율 (0) | 2022.02.10 |
[python, C++] 백준 1292 쉽게 푸는 문제 (0) | 2022.02.03 |
[python, C++] 백준 2953 나는 요리사다 (0) | 2022.02.03 |
[python, C++] 백준 2711 오타맨 고창영 (0) | 2022.02.03 |