📌문제
https://www.acmicpc.net/problem/11497
🎖️난이도
✔️풀이
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <math.h>
#include <tuple>
#include <typeinfo> // operator typeid
using namespace std;
int T;
int N;
int main(void) {
cin >> T;
for (int i = 0; i < T; i++) {
cin >> N;
vector<int> L_v;
int l;
for (int j = 0; j < N; j++) {
cin >> l;
L_v.push_back(l);
}
sort(L_v.begin(), L_v.end());
int tmp_max = 0;
for (int k = 2; k < N; k++) {
tmp_max = max(tmp_max, L_v[k] - L_v[k - 2]);
}
cout << tmp_max << endl;
}
return 0;
}
'[ 알고리즘 ] > Greedy' 카테고리의 다른 글
[프로그래머스] 단속카메라 (0) | 2022.06.29 |
---|---|
[프로그래머스] 구명보트 (0) | 2022.06.29 |
[프로그래머스] 큰 수 만들기 (0) | 2022.06.29 |
[프로그래머스] 체육복 (0) | 2022.06.29 |
[백준] 11501. 주식 (0) | 2022.06.29 |