Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class vovo {
- public static void main(String[] args){
- Scanner tecla = new Scanner(System.in);
- int n = tecla.nextInt();
- int s = tecla.nextInt();
- int total = 0;
- int contador = 0;
- int valor;
- int menor = 100000;
- while(n > contador){
- valor = tecla.nextInt();
- if(contador == 0){
- total += valor + s;
- }if(contador > 0){
- total += valor;
- }if(contador < 0){
- total += valor;
- }if(s < total){
- menor = s;
- }
- else if(menor > total){
- menor = total;
- }
- contador++;
- }
- System.out.println(menor);
- } // Feito por walex!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement