ソースコード 拡げる

Copy
```import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long h = sc.nextInt();
long m = sc.nextInt();
long s = sc.nextInt();
long t0 = h * 3600 + m * 60 + s;
long h0 = t0;
long c1 = sc.nextInt();
long c2 = sc.nextInt();
long t1 = Long.MAX_VALUE;
long t2 = Long.MIN_VALUE;
int x1 = 0,x2 = 0;
for(long t=0;t<10000L*60*3;t++) {
if (x1 == c1 && x2 == c2 && !check3(t0+t)) {
t1 = Math.min(t1, t);
t2 = Math.max(t2, t);
}
//1sec
if (check1(t0 + t)) {
x1++;
}
if (check2(t0 + t)) {
x2++;
}
}
if (t1 == Long.MAX_VALUE) {
System.out.println(-1);
}else{
System.out.println(t1 + " " + t2);
}
}
public static boolean check1(long t) {
long m1 = t % 3600 * 12;
long m2 = m1 + 12;
long s1 = t % 60 * 720;
long s2 = s1 + 720;
return (s1 < m1 && m2 <= s2);
}
public static boolean check2(long t) {
long h1 = t % (3600 * 12);
long h2 = h1 + 1;
long m1 = t % 3600 * 12;
long m2 = m1 + 12;
return (m1 < h1 && h2 <= m2);
}
public static boolean check3(long t) {
long h1 = t % (3600 * 12);
long m1 = t % 3600 * 12;
long s1 = t % 60 * 720;
return (h1 == m1 || s1 == m1);
}
}
```

#### 提出情報

提出日時 2018-02-03 16:54:22+0900 A - アナログ時計 piroz95 Java8 (OpenJDK 1.8.0) 400 1289 Byte AC 149 ms 23252 KB

#### ジャッジ結果

セット名 All

 AC × 36
セット名 テストケース
All _sample_01, _sample_02, _sample_03, _sample_04, corner_01, corner_02, fixed-random-01, fixed-random-02, fixed-random-03, fixed-random-04, fixed-random-05, fixed-random-06, fixed-random-07, fixed-random-08, fixed-random-09, fixed-random-10, large-01, large-02, large-03, large-04, large-05, large-06, large-07, large-08, large-09, large-10, random-01, random-02, random-03, random-04, random-05, random-06, random-07, random-08, random-09, random-10
ケース名 結果 実行時間 メモリ
_sample_01 AC 114 ms 19412 KB
_sample_02 AC 112 ms 19412 KB
_sample_03 AC 113 ms 19796 KB
_sample_04 AC 118 ms 18644 KB
corner_01 AC 118 ms 19924 KB
corner_02 AC 112 ms 18768 KB
fixed-random-01 AC 118 ms 21844 KB
fixed-random-02 AC 149 ms 19028 KB
fixed-random-03 AC 118 ms 21716 KB
fixed-random-04 AC 114 ms 18640 KB
fixed-random-05 AC 117 ms 21844 KB
fixed-random-06 AC 119 ms 21712 KB
fixed-random-07 AC 118 ms 18644 KB
fixed-random-08 AC 119 ms 19668 KB
fixed-random-09 AC 117 ms 19924 KB
fixed-random-10 AC 117 ms 21844 KB
large-01 AC 117 ms 19028 KB
large-02 AC 118 ms 21204 KB
large-03 AC 118 ms 18644 KB
large-04 AC 116 ms 20052 KB
large-05 AC 118 ms 19028 KB
large-06 AC 118 ms 19796 KB
large-07 AC 117 ms 20560 KB
large-08 AC 119 ms 21588 KB
large-09 AC 122 ms 19156 KB
large-10 AC 119 ms 19924 KB
random-01 AC 118 ms 19284 KB
random-02 AC 117 ms 21972 KB
random-03 AC 114 ms 19796 KB
random-04 AC 117 ms 21716 KB
random-05 AC 119 ms 23252 KB
random-06 AC 113 ms 18644 KB
random-07 AC 117 ms 20692 KB
random-08 AC 114 ms 21332 KB
random-09 AC 113 ms 20180 KB
random-10 AC 113 ms 21076 KB