Submission #4296628
Source Code Expand
import java.io.InputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class Main { InputStream in = System.in; PrintStream out = System.out; private static String max(String a, String b) { if(a.compareTo(b)>0) { return a; }else { return b; } } private List<List<String>> seiri(List<List<String>> l){ for(int i=0;i<l.size()-1;i++) { if(l.get(i).get(1).compareTo(l.get(i+1).get(0)) >= 0) { List<List<String>> r = new ArrayList<>(); for(int j=0;j<i-1;j++) { r.add(l.get(j)); } r.add(Arrays.asList( l.get(i).get(0), max(l.get(i).get(1), l.get(i+1).get(1)))); for(int j=i+2;j<l.size();j++) { r.add(l.get(j)); } return seiri(r); } } return l; } public void _main(String[] args) { Scanner sc = new Scanner(in); int n = sc.nextInt(); List<List<String>> l = new ArrayList<>(); for(int i=0;i<n;i++) { String s = sc.next().trim(); int lhs = Integer.parseInt(s.substring(0, 4)); int rhs = Integer.parseInt(s.substring(5, 9)); lhs -= lhs%5; rhs += (5-(rhs%5))%5; l.add(new ArrayList<String>(Arrays.asList(String.format("%04d", lhs),String.format("%04d", rhs)))); } l.sort(new Comparator<List<String>>() { public int compare(List<String> a, List<String> b){ return a.get(0).compareTo(b.get(0)); } }); List<List<String>> result = seiri(l); for(List<String> rr : result) { out.println(rr.get(0)+ "-" + rr.get(1)); } sc.close(); } public static void main(String[] args) { new Main()._main(args); } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | puvon |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1785 Byte |
Status | WA |
Exec Time | 2112 ms |
Memory | 365636 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 | AC | 99 ms | 19156 KB |
00_sample_02.txt | AC | 99 ms | 20688 KB |
00_sample_03.txt | AC | 102 ms | 17748 KB |
cho_cho_chokudai.txt | TLE | 2112 ms | 364456 KB |
chokudai_ga_cho.txt | TLE | 2111 ms | 365560 KB |
test_01.txt | AC | 132 ms | 21588 KB |
test_02.txt | AC | 130 ms | 22100 KB |
test_03.txt | AC | 132 ms | 19540 KB |
test_04.txt | AC | 128 ms | 20180 KB |
test_05.txt | AC | 129 ms | 20944 KB |
test_06.txt | AC | 151 ms | 23380 KB |
test_07.txt | AC | 142 ms | 19016 KB |
test_08.txt | AC | 138 ms | 20944 KB |
test_09.txt | AC | 193 ms | 27552 KB |
test_10.txt | AC | 220 ms | 31720 KB |
test_11.txt | WA | 208 ms | 30136 KB |
test_12.txt | AC | 180 ms | 23636 KB |
test_13.txt | AC | 157 ms | 24268 KB |
test_14.txt | AC | 186 ms | 25040 KB |
test_15.txt | AC | 238 ms | 29464 KB |
test_16.txt | WA | 142 ms | 19540 KB |
test_17.txt | AC | 207 ms | 26704 KB |
test_18.txt | AC | 156 ms | 24404 KB |
test_19.txt | AC | 192 ms | 27224 KB |
test_20.txt | AC | 196 ms | 28320 KB |
test_21.txt | TLE | 2111 ms | 352760 KB |
test_22.txt | TLE | 2107 ms | 350768 KB |
test_23.txt | TLE | 2107 ms | 358020 KB |
test_24.txt | TLE | 2111 ms | 351340 KB |
test_25.txt | TLE | 2111 ms | 351692 KB |
test_26.txt | TLE | 2107 ms | 347816 KB |
test_27.txt | TLE | 2107 ms | 348428 KB |
test_28.txt | TLE | 2107 ms | 349636 KB |
test_29.txt | AC | 103 ms | 21844 KB |
test_30.txt | WA | 110 ms | 19028 KB |
test_31.txt | MLE | 674 ms | 96672 KB |
test_32.txt | WA | 119 ms | 18644 KB |
test_33.txt | TLE | 2064 ms | 351568 KB |
test_34.txt | AC | 101 ms | 17108 KB |
test_35.txt | WA | 160 ms | 22356 KB |
test_36.txt | TLE | 2111 ms | 349868 KB |
test_37.txt | TLE | 2107 ms | 350608 KB |
test_38.txt | TLE | 2108 ms | 365636 KB |
test_39.txt | TLE | 2111 ms | 350468 KB |
test_40.txt | TLE | 2111 ms | 350840 KB |
test_41.txt | TLE | 2107 ms | 351472 KB |
test_42.txt | TLE | 2111 ms | 361924 KB |
test_43.txt | TLE | 2107 ms | 350104 KB |