結果

問題 No.318 学学学学学
ユーザー kou6839
提出日時 2015-12-12 16:40:00
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 698 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 88,744 KB
実行使用メモリ 77,104 KB
最終ジャッジ日時 2024-09-15 08:45:06
合計ジャッジ時間 8,597 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other RE * 17 TLE * 1 -- * 8
権限があれば一括ダウンロードができます

ソースコード

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