結果

問題 No.182 新規性の虜
ユーザー 37zigen
提出日時 2016-03-31 13:42:26
言語 Java
(openjdk 23)
結果
AC  
実行時間 691 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 75,428 KB
実行使用メモリ 53,940 KB
最終ジャッジ日時 2024-12-27 02:57:45
合計ジャッジ時間 14,147 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
}
0