Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Date;
- import java.util.Scanner;
- public class Main {
- @SuppressWarnings("deprecation")
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- while(s.hasNext()) {
- String l = s.nextLine();
- if (l.equals("0")) {
- break;
- }
- int lines = Integer.parseInt(l);
- String currentLine = null;
- Date[] dates = new Date[lines];
- int[] marker = new int[lines];
- String[] currlinedata = null;
- for (int i = 0; i < lines; i++) {
- currentLine = s.nextLine();
- currlinedata = currentLine.split(" ");
- dates[i] = new Date(Integer.parseInt(currlinedata[2])-1900, Integer.parseInt(currlinedata[1])-1, Integer.parseInt(currlinedata[0]));
- marker[i] = Integer.parseInt(currlinedata[3]);
- }
- int counter = 0;
- int markerCounter = 0;
- for (int i = 0; i < lines-1; i++) {
- if(dates[i+1].getTime() - dates[i].getTime() == 1000 * 60 * 60 * 24) {
- counter++;
- markerCounter += (marker[i+1] - marker[i]);
- }
- }
- System.out.println(counter + " " + markerCounter);
- }
- s.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement