Skip to content

Instantly share code, notes, and snippets.

@anitainfo
Last active November 5, 2020 14:41
Show Gist options
  • Save anitainfo/afd0f5c5570de7f3edb92bf059c5e04b to your computer and use it in GitHub Desktop.
Save anitainfo/afd0f5c5570de7f3edb92bf059c5e04b to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h> //biblioteca utilizada
using namespace std;
int main()
{
int N, v[3], res=0; //declaração de variáveis
scanf("%d", &N); //leitura do 'N'
scanf("%d %d %d", &v[0], &v[1], &v[2]); //leitura do 'X', 'Y' e 'Z'
sort(v,v+3); //ordenação crescente
for(int i=0; i<3; i++) //loop para checar todos os 3 valores X,Y,Z já ordenados
{
N-=v[i]; //subtrai o valor da posição 'i' no vetor 'v[]' de 'N' (total)
if(N>=0)res++; //se o 'N' ainda não é menor que 0, acrescenta-se 1 na resposta final 'res'
}
printf("%d", res); //imprime a resposta 'res'
return 0; //retorna a 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment