forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.java
49 lines (33 loc) · 1.33 KB
/
Solution.java
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
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the libraryFine function below.
static int libraryFine(int dR, int mR, int yR, int dD, int mD, int yD) {
if (yR > yD) { return 10000; }
if (mR > mD && yR == yD) { return 500 * (mR - mD); }
if (dR > dD && mR == mD && yR == yD) { return 15 * (dR - dD); }
return 0;
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String[] d1M1Y1 = scanner.nextLine().split(" ");
int d1 = Integer.parseInt(d1M1Y1[0]);
int m1 = Integer.parseInt(d1M1Y1[1]);
int y1 = Integer.parseInt(d1M1Y1[2]);
String[] d2M2Y2 = scanner.nextLine().split(" ");
int d2 = Integer.parseInt(d2M2Y2[0]);
int m2 = Integer.parseInt(d2M2Y2[1]);
int y2 = Integer.parseInt(d2M2Y2[2]);
int result = libraryFine(d1, m1, y1, d2, m2, y2);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
bufferedWriter.close();
scanner.close();
}
}