結果
問題 | No.318 学学学学学 |
ユーザー | jp_ste |
提出日時 | 2016-01-30 14:05:57 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,381 bytes |
コンパイル時間 | 3,034 ms |
コンパイル使用メモリ | 80,456 KB |
実行使用メモリ | 78,440 KB |
最終ジャッジ日時 | 2023-10-21 17:56:13 |
合計ジャッジ時間 | 34,567 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 437 ms
49,300 KB |
testcase_01 | AC | 581 ms
50,756 KB |
testcase_02 | WA | - |
testcase_03 | AC | 524 ms
50,172 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,456 ms
74,660 KB |
testcase_18 | AC | 1,454 ms
74,048 KB |
testcase_19 | AC | 1,539 ms
76,536 KB |
testcase_20 | WA | - |
testcase_21 | AC | 135 ms
41,152 KB |
testcase_22 | AC | 149 ms
41,328 KB |
testcase_23 | AC | 150 ms
41,312 KB |
testcase_24 | AC | 137 ms
40,160 KB |
testcase_25 | AC | 150 ms
41,476 KB |
testcase_26 | AC | 147 ms
41,460 KB |
testcase_27 | AC | 151 ms
41,412 KB |
testcase_28 | AC | 134 ms
40,156 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]; 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() >= 2) { int from = array.get(0); int to = array.get(array.size()-1); for(int i=from; i<=to; i++) { if(list[i] > t) break; list[i] = t; } } } for(int i=0; i<N; i++) { if(i==0) { System.out.print(list[i]); } else { System.out.print(" " + list[i]); } } } }