結果

問題 No.182 新規性の虜
ユーザー 37zigen37zigen
提出日時 2016-08-25 16:05:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 694 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 3,266 ms
コンパイル使用メモリ 74,344 KB
実行使用メモリ 66,920 KB
最終ジャッジ日時 2023-08-27 12:45:32
合計ジャッジ時間 15,056 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,972 KB
testcase_01 AC 127 ms
55,812 KB
testcase_02 AC 128 ms
55,880 KB
testcase_03 AC 128 ms
55,408 KB
testcase_04 AC 127 ms
56,024 KB
testcase_05 AC 129 ms
55,732 KB
testcase_06 AC 128 ms
55,580 KB
testcase_07 AC 131 ms
55,828 KB
testcase_08 AC 540 ms
60,992 KB
testcase_09 AC 668 ms
61,268 KB
testcase_10 AC 632 ms
60,784 KB
testcase_11 AC 614 ms
60,668 KB
testcase_12 AC 420 ms
60,396 KB
testcase_13 AC 123 ms
55,668 KB
testcase_14 AC 127 ms
55,344 KB
testcase_15 AC 123 ms
55,984 KB
testcase_16 AC 127 ms
55,464 KB
testcase_17 AC 130 ms
56,172 KB
testcase_18 AC 586 ms
60,352 KB
testcase_19 AC 479 ms
60,896 KB
testcase_20 AC 429 ms
60,648 KB
testcase_21 AC 587 ms
60,472 KB
testcase_22 AC 438 ms
60,428 KB
testcase_23 AC 122 ms
55,576 KB
testcase_24 AC 694 ms
66,920 KB
testcase_25 AC 486 ms
60,408 KB
testcase_26 AC 277 ms
59,848 KB
testcase_27 AC 123 ms
56,220 KB
evil01.txt AC 737 ms
67,084 KB
evil02.txt AC 731 ms
67,132 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