-
-
Save veigavitor/071505c729134f84884e52c475ad4590 to your computer and use it in GitHub Desktop.
This file contains 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 <bits/stdc++.h> | |
using namespace std; | |
int32_t main() { | |
ios::sync_with_stdio(false); | |
cin.tie(nullptr); | |
// lê-se a entrada | |
int n; | |
cin >> n; | |
vector<int> v(n); | |
for(int i = 0; i < n; i++) { | |
cin >> v[i]; | |
} | |
// adiciona no vetor de pesos um 0, pois quando o elevador | |
// está vazio, é como se ele estivesse com um peso zero | |
v.push_back(0); | |
// ordena o vetor | |
sort(v.begin(), v.end()); | |
bool ok = true; | |
// checa se entre dois pesos adjacentes há uma diferença de mais de 8 unidades | |
for(int i = 1; i < n+1; i++) { | |
if(v[i] - v[i-1] > 8) ok = false; | |
} | |
// retorna se é possível ou não levar os pesos para o segundo andar | |
if(ok) cout << "S" << endl; | |
else cout << "N" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment