Submission #335306
Source Code Expand
import java.util.*; public class Main { public static void main(String[] args) { int n; Integer [] start, end; Scanner sc = new Scanner(System.in); n = sc.nextInt(); start = new Integer[n]; end = new Integer[n]; //降り始めと振り終わりに分ける separate(start,end, n, sc); //降り始めを基準にして昇順にソート ssort(start, end, n); //雨が振った時間がかぶっている場合合成 connect(start, end, n); //重複なしで出力 normalization(start, end, n); } private static void separate(Integer[] start, Integer[] end, int n, Scanner sc) { int i, tmp; for(i = 0; i < n; i++){ String[] change = (sc.next()).split("-"); tmp = Integer.parseInt(change[0]); start[i] = (tmp - (tmp % 5)); tmp = Integer.parseInt(change[1]) + 4; end[i] = tmp - (tmp % 5); //System.out.println(start[i]); //System.out.println(end[i]); } } private static void ssort(Integer[] start, Integer[] end, int n) { int i,k, idx, tmp, min; for(i = 0; i < n; i++){ min = start[i]; idx = i; for(k = i + 1; k < n; k++){ if(start[k] < min){ min = start[k]; idx = k; } } tmp = start[idx]; start[idx] = start[i]; start[i] = tmp; tmp = end[idx]; end[idx] = end[i]; end[i] = tmp; } } private static void connect(Integer[] start, Integer[] end, int n) { int i,k,s,e,s2,e2; for(i = 0; i < n; i++){ s = start[i]; e = end[i]; for(k = i + 1; k < n; k++){ s2 = start[k]; e2 = end[k]; if(s2 <= e){ start[k] = start[i]; if(e2 <= e){ end[k] = end[i]; } else { end[i] = end[k]; } } } } } private static void normalization(Integer[] start, Integer[] end, int n) { int i,search; search = start[0]; System.out.println(String.format("%04d-%04d", start[0], end[0])); for(i = 0; i < n; i++){ //System.out.println(start[i] + "-" + end[i]); if(search != start[i]){ System.out.println(String.format("%04d-%04d", start[i], end[i])); search = start[i]; } } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | ne260037 |
Language | Java (OpenJDK 1.7.0) |
Score | 0 |
Code Size | 2155 Byte |
Status | TLE |
Exec Time | 2044 ms |
Memory | 39896 KB |
Judge Result
Set Name | all | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | WA | 346 ms | 23220 KB |
00_sample_02.txt | AC | 343 ms | 23336 KB |
00_sample_03.txt | AC | 340 ms | 23336 KB |
cho_cho_chokudai.txt | TLE | 2040 ms | 38364 KB |
chokudai_ga_cho.txt | TLE | 2042 ms | 39076 KB |
test_01.txt | AC | 416 ms | 23744 KB |
test_02.txt | AC | 414 ms | 23760 KB |
test_03.txt | AC | 409 ms | 23784 KB |
test_04.txt | AC | 414 ms | 23788 KB |
test_05.txt | AC | 404 ms | 23732 KB |
test_06.txt | AC | 401 ms | 24608 KB |
test_07.txt | WA | 377 ms | 23452 KB |
test_08.txt | AC | 367 ms | 23376 KB |
test_09.txt | AC | 470 ms | 26684 KB |
test_10.txt | WA | 461 ms | 25876 KB |
test_11.txt | AC | 435 ms | 24992 KB |
test_12.txt | AC | 414 ms | 24516 KB |
test_13.txt | WA | 396 ms | 24640 KB |
test_14.txt | WA | 462 ms | 26072 KB |
test_15.txt | AC | 467 ms | 26016 KB |
test_16.txt | WA | 391 ms | 24796 KB |
test_17.txt | WA | 460 ms | 26040 KB |
test_18.txt | WA | 392 ms | 24848 KB |
test_19.txt | AC | 420 ms | 24760 KB |
test_20.txt | WA | 435 ms | 25128 KB |
test_21.txt | TLE | 2042 ms | 39288 KB |
test_22.txt | TLE | 2041 ms | 39120 KB |
test_23.txt | TLE | 2044 ms | 39896 KB |
test_24.txt | TLE | 2041 ms | 39784 KB |
test_25.txt | TLE | 2042 ms | 39168 KB |
test_26.txt | TLE | 2041 ms | 39120 KB |
test_27.txt | TLE | 2041 ms | 39048 KB |
test_28.txt | TLE | 2042 ms | 39136 KB |
test_29.txt | AC | 349 ms | 23352 KB |
test_30.txt | WA | 353 ms | 23284 KB |
test_31.txt | WA | 669 ms | 29392 KB |
test_32.txt | WA | 349 ms | 23380 KB |
test_33.txt | TLE | 2041 ms | 38240 KB |
test_34.txt | AC | 347 ms | 23288 KB |
test_35.txt | WA | 405 ms | 24864 KB |
test_36.txt | TLE | 2042 ms | 39888 KB |
test_37.txt | TLE | 2042 ms | 39148 KB |
test_38.txt | TLE | 2042 ms | 39196 KB |
test_39.txt | TLE | 2041 ms | 38932 KB |
test_40.txt | TLE | 2041 ms | 39000 KB |
test_41.txt | TLE | 2040 ms | 38984 KB |
test_42.txt | TLE | 2040 ms | 39032 KB |
test_43.txt | TLE | 2041 ms | 39548 KB |