자기개발👨💻/코딩 알고리즘
[C++] 백준 5054 주차의 신
천숭이
2022. 2. 3. 21:27
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;
}
}

도저히 문제 이해가 되지않아 문제 해결 방법은 구글링 해서 푼 문제,,,