Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- public class Main {
- public static void main(String[] args) throws Exception {
- BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
- PrintWriter w = new PrintWriter(System.out);
- String[] inputs = r.readLine().split("[,:}\"]");
- long totalDelta = 0;
- int totalCM = 0;
- for (int i = 0; i < inputs.length; i++) {
- //System.out.println(inputs[i]);
- if (inputs[i].equals("oldRating")) {
- int oldRating = Integer.parseInt(inputs[i + 2]);
- int newRating = Integer.parseInt(inputs[i + 6]);
- if (1900 <= oldRating && oldRating < 2100) {
- totalCM++;
- totalDelta += newRating - oldRating;
- System.out.println(oldRating + " -> " + newRating);
- }
- }
- }
- System.out.println("Total delta for CM is " + totalDelta);
- System.out.println("Total CM count is " + totalCM);
- System.out.println("Average delta is " + (1.0 * totalDelta) / totalCM);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement