結果

問題 No.182 新規性の虜
ユーザー 37zigen37zigen
提出日時 2016-03-31 13:42:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 650 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 73,896 KB
実行使用メモリ 67,380 KB
最終ジャッジ日時 2023-08-27 10:35:19
合計ジャッジ時間 13,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,532 KB
testcase_01 AC 119 ms
55,728 KB
testcase_02 AC 119 ms
55,888 KB
testcase_03 AC 122 ms
56,012 KB
testcase_04 AC 120 ms
55,500 KB
testcase_05 AC 123 ms
56,096 KB
testcase_06 AC 118 ms
56,160 KB
testcase_07 AC 124 ms
55,908 KB
testcase_08 AC 530 ms
61,260 KB
testcase_09 AC 650 ms
60,892 KB
testcase_10 AC 619 ms
60,732 KB
testcase_11 AC 605 ms
60,916 KB
testcase_12 AC 417 ms
60,360 KB
testcase_13 AC 119 ms
55,772 KB
testcase_14 AC 125 ms
55,824 KB
testcase_15 AC 120 ms
55,520 KB
testcase_16 AC 121 ms
55,668 KB
testcase_17 AC 125 ms
55,984 KB
testcase_18 AC 559 ms
60,580 KB
testcase_19 AC 471 ms
60,748 KB
testcase_20 AC 382 ms
60,636 KB
testcase_21 AC 563 ms
60,772 KB
testcase_22 AC 412 ms
60,740 KB
testcase_23 AC 117 ms
55,448 KB
testcase_24 AC 642 ms
67,380 KB
testcase_25 AC 490 ms
60,320 KB
testcase_26 AC 281 ms
59,996 KB
testcase_27 AC 114 ms
55,728 KB
evil01.txt AC 716 ms
67,644 KB
evil02.txt AC 750 ms
66,788 KB
権限があれば一括ダウンロードができます

ソースコード

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