結果
問題 | No.318 学学学学学 |
ユーザー | jp_ste |
提出日時 | 2016-01-30 15:19:28 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,614 bytes |
コンパイル時間 | 3,021 ms |
コンパイル使用メモリ | 83,608 KB |
実行使用メモリ | 104,580 KB |
最終ジャッジ日時 | 2023-10-21 17:57:12 |
合計ジャッジ時間 | 33,050 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 455 ms
62,924 KB |
testcase_01 | AC | 636 ms
65,156 KB |
testcase_02 | WA | - |
testcase_03 | AC | 557 ms
64,884 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 1,397 ms
76,904 KB |
testcase_18 | AC | 1,389 ms
78,168 KB |
testcase_19 | AC | 1,475 ms
76,920 KB |
testcase_20 | WA | - |
testcase_21 | AC | 129 ms
46,012 KB |
testcase_22 | AC | 142 ms
46,288 KB |
testcase_23 | AC | 144 ms
57,756 KB |
testcase_24 | AC | 149 ms
48,280 KB |
testcase_25 | AC | 142 ms
46,324 KB |
testcase_26 | AC | 144 ms
46,224 KB |
testcase_27 | AC | 144 ms
46,496 KB |
testcase_28 | AC | 149 ms
46,260 KB |
ソースコード
import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int list[] = new int[N]; boolean flag[] = new boolean[N]; HashMap<Integer, ArrayList<Integer>> pathMap = new HashMap<>(); Comparator<Integer> comp = new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { return o2.compareTo(o1); } }; TreeSet<Integer> checkList = new TreeSet<Integer>(comp); for(int i=0; i<N; i++) { int a = scan.nextInt(); list[i] = a; ArrayList<Integer> array = pathMap.get(a); if( array == null) { array = new ArrayList<>(); array.add(i); pathMap.put(a, array); } else { array.add(i); pathMap.put(a, array); } checkList.add(a); } scan.close(); for(int t : checkList) { //System.out.println("t : " + t); ArrayList<Integer> array = pathMap.get(t); if(array == null) continue; if(array.size() == 1) { int index=array.get(0); if(flag[index]==false) { list[index] = t; flag[index] = true; } }else if(array.size() >= 2) { int from = array.get(0); int to = array.get(array.size()-1); for(int i=from; i<=to; i++) { if(flag[i]) { break; } else { list[i] = t; flag[i] = true; } } } } for(int i=0; i<N; i++) { if(i==0) { System.out.print(list[i]); } else { System.out.print(" " + list[i]); } } } }