SHARE
TWEET

Untitled

a guest May 22nd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class InnaAndDima {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int n = scanner.nextInt();
  8.         int[] notesMaxVolume = new int[n];
  9.         for (int i = 0; i < notesMaxVolume.length; i++) {
  10.             notesMaxVolume[i] = scanner.nextInt();
  11.         }
  12.         int countHappiness = 0;
  13.         for(int maxVolume : notesMaxVolume) {
  14.             int neededVolume = scanner.nextInt();
  15.             if(Math.abs(neededVolume - maxVolume) <= maxVolume && Math.abs(neededVolume - maxVolume) >= 1) {
  16.                 countHappiness += maxVolume * (neededVolume - maxVolume);
  17.             } else {
  18.                 countHappiness--;
  19.             }
  20.         }
  21.         System.out.println(countHappiness);
  22.     }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top