結果
| 問題 | No.318 学学学学学 |
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2015-12-12 16:53:05 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 789 bytes |
| 記録 | |
| コンパイル時間 | 2,591 ms |
| コンパイル使用メモリ | 85,664 KB |
| 実行使用メモリ | 75,048 KB |
| 最終ジャッジ日時 | 2024-09-15 08:46:46 |
| 合計ジャッジ時間 | 9,346 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | WA * 6 TLE * 1 -- * 19 |
ソースコード
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);
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);
}
}
kou6839