結果
問題 |
No.318 学学学学学
|
ユーザー |
![]() |
提出日時 | 2015-12-12 16:45:44 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 836 bytes |
コンパイル時間 | 2,469 ms |
コンパイル使用メモリ | 91,220 KB |
実行使用メモリ | 69,876 KB |
最終ジャッジ日時 | 2024-09-15 08:45:55 |
合計ジャッジ時間 | 9,361 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | WA * 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] = 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); } }