Advertisement
Guest User

Walexhenrique

a guest
May 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class vovo {
  4. public static void main(String[] args){
  5. Scanner tecla = new Scanner(System.in);
  6. int n = tecla.nextInt();
  7. int s = tecla.nextInt();
  8. int total = 0;
  9. int contador = 0;
  10. int valor;
  11. int menor = 100000;
  12. while(n > contador){
  13. valor = tecla.nextInt();
  14. if(contador == 0){
  15. total += valor + s;
  16. }if(contador > 0){
  17. total += valor;
  18. }if(contador < 0){
  19. total += valor;
  20. }if(s < total){
  21. menor = s;
  22. }
  23. else if(menor > total){
  24. menor = total;
  25. }
  26. contador++;
  27. }
  28. System.out.println(menor);
  29. } // Feito por walex!
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement