Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.sql.Date;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     @SuppressWarnings("deprecation")
  7.     public static void main(String[] args) {
  8.         Scanner s = new Scanner(System.in);
  9.         while(s.hasNext()) {
  10.             String l = s.nextLine();
  11.             if (l.equals("0")) {
  12.                 break;
  13.             }
  14.             int lines = Integer.parseInt(l);
  15.             String currentLine = null;
  16.             Date[] dates = new Date[lines];
  17.             int[] marker = new int[lines];
  18.             String[] currlinedata = null;
  19.             for (int i = 0; i < lines; i++) {
  20.                 currentLine = s.nextLine();
  21.                 currlinedata = currentLine.split(" ");
  22.                 dates[i] = new Date(Integer.parseInt(currlinedata[2])-1900, Integer.parseInt(currlinedata[1])-1, Integer.parseInt(currlinedata[0]));
  23.                 marker[i] = Integer.parseInt(currlinedata[3]);
  24.             }
  25.            
  26.             int counter = 0;
  27.             int markerCounter = 0;
  28.             for (int i = 0; i < lines-1; i++) {
  29.                 if(dates[i+1].getTime() - dates[i].getTime() == 1000 * 60 * 60 * 24) {
  30.                     counter++;
  31.                     markerCounter += (marker[i+1] - marker[i]);
  32.                 }
  33.             }
  34.            
  35.             System.out.println(counter + " " + markerCounter);
  36.            
  37.         }
  38.         s.close();
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement