Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement