Skip to content

Instantly share code, notes, and snippets.

@estelabn
Created September 26, 2023 23:50
Show Gist options
  • Save estelabn/328b805273569849e43f95f906393abc to your computer and use it in GitHub Desktop.
Save estelabn/328b805273569849e43f95f906393abc to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main(){
int N; cin >> N;
vector<int> palitos;
for(int i=0; i<N; i++){
int A; cin >> A;
palitos.push_back(A);
}
sort(palitos.begin(), palitos.end());
int resposta = 1e9;
for(int i=1; i<N; i++){
int diferenca = palitos[i] - palitos[i-1];
resposta = min(resposta, diferenca);
}
cout << resposta << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment