-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa12148.java
More file actions
50 lines (46 loc) · 1.26 KB
/
UVa12148.java
File metadata and controls
50 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// WA, but passes sample, uDebug, and discussion
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Main
{
static PrintStream out = System.out;
static PrintStream err = System.err;
static final int INF = 1000000000;
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
// if necessary
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int n = in.nextInt();
while (n != 0)
{
GregorianCalendar curDate = null, lastDate = null;
int curValue = 0, lastValue = 0;
int certainDays = 0, certainAmt = 0;
for (int i = 0; i < n; i++)
{
int day = in.nextInt(), month = in.nextInt(), year = in.nextInt(), value = in.nextInt();
lastDate = curDate;
curDate = new GregorianCalendar(year, month - 1, day);
lastValue = curValue;
curValue = value;
if (i != 0)
{
lastDate.add(Calendar.DAY_OF_YEAR, 1);
if (lastDate.equals(curDate))
{
certainDays++;
certainAmt += curValue - lastValue;
}
}
}
out.printf("%d %d%n", certainDays, certainAmt);
n = in.nextInt();
}
// pr.close();
}
}