結果
問題 |
No.182 新規性の虜
|
ユーザー |
|
提出日時 | 2016-08-25 16:05:37 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 768 ms / 5,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 4,461 ms |
コンパイル使用メモリ | 75,320 KB |
実行使用メモリ | 52,864 KB |
最終ジャッジ日時 | 2024-12-27 08:09:52 |
合計ジャッジ時間 | 18,168 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
package yukicoder182; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); PriorityQueue<Integer> pq=new PriorityQueue<>(n); for(int i=0;i<n;i++){ pq.add(sc.nextInt()); } int count=1; int memo=pq.poll(); while(!pq.isEmpty()){ int t=pq.poll(); if(t!=memo){ count++; memo=t; }else{ count--; while(t==memo&&!pq.isEmpty()){ t=pq.poll(); if(t!=memo)pq.add(t); } } } System.out.println(count); } }