Advertisement
Guest User

Untitled

a guest
Jan 7th, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class test {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String input = scan.nextLine();
  8.  
  9.         String[] splited = input.split("\\s+");
  10.  
  11.         double sum1 = 0;
  12.         double sum2 = 0;
  13.  
  14.         for (int i = 0; i < splited.length / 2; i++) {
  15.  
  16.  
  17.             if (Integer.parseInt(splited[i]) != 0) {
  18.                 sum1 += Integer.parseInt(splited[i]);
  19.             } else {
  20.                 sum1 *= 0.8;
  21.             }
  22.         }
  23.  
  24.         for (int i = splited.length - 1; i > splited.length / 2; i--) {
  25.  
  26.             if (Integer.parseInt(splited[i]) != 0) {
  27.                 sum2 += Integer.parseInt(splited[i]);
  28.             } else {
  29.                 sum2 *= 0.8;
  30.             }
  31.         }
  32.  
  33.         if (sum1 < sum2) {
  34.             System.out.printf("The winner is left with total time: %.1f", sum1);
  35.         }else {
  36.             System.out.printf("The winner is right with total time: %.1f", sum2);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement