Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class B390 {
- public static void main(String[] args) {
- BigInteger happiness = BigInteger.valueOf(0);
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- int[] a = new int[n];
- int[] b = new int[n];
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < n; j++) {
- if (i == 0) {
- a[j] = sc.nextInt();
- } else {
- b[j] = sc.nextInt();
- }
- }
- }
- BigInteger x;
- BigInteger y;
- for (int i = 0; i < n; i++) {
- if (b[i] == 1) {
- happiness = happiness.subtract(BigInteger.valueOf(1));
- }
- if (a[i] * 2 < b[i]) {
- happiness = happiness.subtract(BigInteger.valueOf(1));
- } else {
- if (b[i] % 2 == 0) {
- x = BigInteger.valueOf(b[i] / 2);
- happiness = happiness.add(x.multiply(x));
- } else {
- x = BigInteger.valueOf((b[i] - 1) / 2);
- y = BigInteger.valueOf((b[i] + 1) / 2);
- happiness = happiness.add(x.multiply(y));
- }
- }
- }
- System.out.println(happiness);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement