結果

問題 No.318 学学学学学
ユーザー kou6839kou6839
提出日時 2015-12-12 16:40:00
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 698 bytes
コンパイル時間 2,415 ms
コンパイル使用メモリ 83,044 KB
実行使用メモリ 71,912 KB
最終ジャッジ日時 2023-10-13 11:48:02
合計ジャッジ時間 9,090 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 TLE -
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.*;

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);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] last = new int[101010];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			last[a[i]] = i;
		}
		PriorityQueue<Integer> s = new PriorityQueue<>((x,y)->y-x);
		for(int i=0;i<n;i++){
			if(!s.contains(a[i]))s.add(a[i]);
			System.out.print(s.peek());
			if(last[a[i]]==i) s.remove(a[i]);
			if(i==n-1){
				System.out.println();
			}else{
				System.out.print(" ");
			}
		}
		
	}
}
0