結果
問題 |
No.318 学学学学学
|
ユーザー |
![]() |
提出日時 | 2015-12-12 16:43:56 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 770 bytes |
コンパイル時間 | 2,627 ms |
コンパイル使用メモリ | 90,616 KB |
実行使用メモリ | 70,184 KB |
最終ジャッジ日時 | 2024-09-15 08:45:31 |
合計ジャッジ時間 | 12,177 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 6 TLE * 1 -- * 19 |
ソースコード
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] = sc.nextInt(); last.put(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.get(a[i])==i) s.remove(a[i]); if(i==n-1){ System.out.println(); }else{ System.out.print(" "); } } } }