結果

問題 No.318 学学学学学
ユーザー kou6839kou6839
提出日時 2015-12-12 16:51:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 4,367 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 77,888 KB
最終ジャッジ日時 2023-10-13 11:49:43
合計ジャッジ時間 10,861 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

import javax.print.attribute.HashAttributeSet;

public class Main {
	static long gcd(long a,long b){
		return b == 0 ? a : gcd(b, a%b);
	}
	static long lcm(long a, long b){
		return a*b/gcd(a, b);
	}
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> last = new HashMap<>();
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = Integer.parseInt(sc.next());
			last.put(a[i], i);
		}
		PriorityQueue<Integer> s = new PriorityQueue<>((x,y)->y-x);
		StringBuilder ans = new StringBuilder();
		for(int i=0;i<n;i++){
			if(!s.contains(a[i]))s.add(a[i]);
			ans.append(s.peek());
			if(last.get(a[i])<=i) s.remove(a[i]);
			if(i==n-1){
				ans.append("\n");
			}else{
				ans.append(" ");
			}
		}
		System.out.println(ans);
	}
}
0