inhuman_Arif

Average Score 6969

May 5th, 2023
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main {
  5.     public static void main(String[] args) throws IOException {
  6. //        System.setIn(new FileInputStream(new File("/home/arif/Documents/inout/input.txt")));
  7. //        System.setOut(new PrintStream(new File("/home/arif/Documents/inout/output.txt")));
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int tc = scanner.nextInt();
  11.         while (tc-- >0) {
  12.             int bob = scanner.nextInt();
  13.             int other = scanner.nextInt();
  14.             int bobSum = 0;
  15.             int otherSum = 0;
  16.             for (int i=0;i<bob-1;i++){
  17.                 int x = scanner.nextInt();
  18.                 bobSum+=x;
  19.             }
  20.             for (int i=0;i<other;i++){
  21.                 int x = scanner.nextInt();
  22.                 otherSum+=x;
  23.             }
  24.             int min = (otherSum/other)+1;
  25.             int max = (int) (Math.ceil((double) bobSum/(double) (bob-1))-1);
  26.             System.out.println(min + " " + max);
  27.         }
  28.  
  29.         scanner.close();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment