Guest User

Untitled

a guest
Nov 5th, 2018
545
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. import java.io.PrintWriter;
  4.  
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) throws Exception {
  9. BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
  10. PrintWriter w = new PrintWriter(System.out);
  11.  
  12. String[] inputs = r.readLine().split("[,:}\"]");
  13.  
  14. long totalDelta = 0;
  15. int totalCM = 0;
  16.  
  17. for (int i = 0; i < inputs.length; i++) {
  18. //System.out.println(inputs[i]);
  19.  
  20. if (inputs[i].equals("oldRating")) {
  21. int oldRating = Integer.parseInt(inputs[i + 2]);
  22. int newRating = Integer.parseInt(inputs[i + 6]);
  23.  
  24. if (1900 <= oldRating && oldRating < 2100) {
  25. totalCM++;
  26. totalDelta += newRating - oldRating;
  27.  
  28. System.out.println(oldRating + " -> " + newRating);
  29. }
  30. }
  31. }
  32.  
  33. System.out.println("Total delta for CM is " + totalDelta);
  34. System.out.println("Total CM count is " + totalCM);
  35. System.out.println("Average delta is " + (1.0 * totalDelta) / totalCM);
  36. }
  37.  
  38. }
RAW Paste Data