結果

問題 No.182 新規性の虜
ユーザー す
提出日時 2024-08-08 10:56:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 8,113 bytes
コンパイル時間 2,497 ms
コンパイル使用メモリ 81,732 KB
実行使用メモリ 48,372 KB
最終ジャッジ日時 2024-08-08 10:56:10
合計ジャッジ時間 6,192 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
36,948 KB
testcase_01 AC 47 ms
36,948 KB
testcase_02 AC 44 ms
36,832 KB
testcase_03 AC 44 ms
37,172 KB
testcase_04 AC 45 ms
37,024 KB
testcase_05 AC 46 ms
37,300 KB
testcase_06 AC 46 ms
37,264 KB
testcase_07 AC 45 ms
36,940 KB
testcase_08 AC 120 ms
45,344 KB
testcase_09 AC 134 ms
45,620 KB
testcase_10 AC 133 ms
45,428 KB
testcase_11 AC 127 ms
45,152 KB
testcase_12 AC 98 ms
40,864 KB
testcase_13 AC 45 ms
37,108 KB
testcase_14 AC 45 ms
37,368 KB
testcase_15 AC 46 ms
37,192 KB
testcase_16 AC 45 ms
37,080 KB
testcase_17 AC 45 ms
36,976 KB
testcase_18 AC 106 ms
42,292 KB
testcase_19 AC 100 ms
41,440 KB
testcase_20 AC 92 ms
40,436 KB
testcase_21 AC 114 ms
44,008 KB
testcase_22 AC 100 ms
40,756 KB
testcase_23 AC 44 ms
37,132 KB
testcase_24 AC 133 ms
48,372 KB
testcase_25 AC 91 ms
38,816 KB
testcase_26 AC 79 ms
39,124 KB
testcase_27 AC 45 ms
37,208 KB
evil01.txt AC 147 ms
48,644 KB
evil02.txt AC 139 ms
48,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) {
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		HashSet<Integer> set2 = new HashSet<>();
		for (int i=0; i<n; i++) {
			int a = sc.nextInt();
			if (set.contains(a)) {
				set2.add(a);
			} else {
				set.add(a);
			}
		}
		out.println(set.size() - set2.size());
		out.flush();
	}

	private static FastScanner sc = new FastScanner();
	private static FastPrinter out = new FastPrinter();
	@SuppressWarnings("unused")
	private static class FastScanner {
        private final BufferedInputStream reader=new BufferedInputStream(System.in);
        private final byte[]buffer=new byte[0x10000];
        private int i=0,length=0;
        private long sum=0,high=-9223372036854775807L,low=9223372036854775807L;

        public int read(){
            if(i==length){
                i=0;
            	try{length=reader.read(buffer);}
                catch(IOException ignored){}
                if(length==-1)return 0;
            }
            if(length<=i)throw new RuntimeException();
            return buffer[i++];
        }

        String next(){
            StringBuilder sb=new StringBuilder();
            int b=read();
            while(b<'!'||'~'<b){b=read();}
            while('!'<=b&&b<='~'){sb.appendCodePoint(b);b=read();}
            return sb.toString();
        }

        String nextLine(){
            StringBuilder sb=new StringBuilder();
            int b=read();
            while(b!=0&&b!='\r'&&b!='\n'){sb.appendCodePoint(b);b=read();}
            if(b=='\r')read();
            return sb.toString();
        }

        int nextInt(){return Math.toIntExact(nextLong());}

        long nextLong(){
            int b=read();while(b<'!'||'~'<b){b=read();}
            boolean neg=false;
            if(b=='-'){neg=true;b=read();}
            long n=0;int c=0;
            while('0'<=b&&b<='9'){n=n*10+b-'0';b=read();c++;}
            if(c==0||c>=2&&n==0)throw new NumberFormatException();
            return neg?-n:n;
        }

        double nextDouble(){return Double.parseDouble(next());}

        String[]nextStrings(int n){
            String[]s=new String[n];
            for(int i=0;i<n;i++)s[i]=next();
            return s;
        }

        String[][]nextStringMat(int n,int m){
            String[][]s=new String[n][m];
            for(int i=0;i<n;i++)s[i]=nextStrings(m);
            return s;
        }

        char[]nextChars(){return next().toCharArray();}

        char[]nextChars(int n){
        	char[]c=new char[n];
        	for(int i=0;i<n;i++)c[i]=next().charAt(0);
        	return c;
        }

        char[]nextSortedChars(){
            char[]c=nextChars();
            Arrays.sort(c);
        	return c;
        }

        char[]nextSortedChars(int n){
            char[]c=nextChars(n);
            Arrays.sort(c);
        	return c;
        }

        char[][]nextCharMat(int n){
            char[][]c=new char[n][];
            for(int i=0;i<n;i++)c[i]=nextChars();
            return c;
        }

        char[][]nextCharMat(int n,int m){
            char[][]c=new char[n][m];
            for(int i=0;i<n;i++)c[i]=nextChars(m);
            return c;
        }

        int[]nextInts(int n){
            int[]a=new int[n];
            for(int i=0;i<n;i++){a[i]=nextInt();sum+=a[i];
            	if(high<a[i])high=a[i];if(low>a[i])low=a[i];}
            return a;
        }

        Integer[]nextIntegers(int n){
            Integer[]a=new Integer[n];
            for(int i=0;i<n;i++){a[i]=nextInt();sum+=a[i];
            	if(high<a[i])high=a[i];if(low>a[i])low=a[i];}
            return a;
        }

        int[]nextSortedInts(int n){
        	int[]a=nextInts(n);Arrays.sort(a);return a;
        }

        Integer[]nextSortedIntegers(int n){
        	Integer[]a=nextIntegers(n);Arrays.sort(a);return a;
        }

        int[]nextIntSum(int n){
        	int[]a=new int[n];a[0]=nextInt();
            for(int i=1;i<n;i++)a[i]=nextInt()+a[i-1];
            return a;
        }

        int[]nextSortedIntSum(int n){
        	int[]a=nextSortedInts(n);
        	for(int i=1;i<n;i++)a[i]+=a[i-1];
        	return a;
        }

        int[][]nextIntMat(int h,int w){
            int[][]a=new int[h][w];
            for(int i=0;i<h;i++)a[i]=nextInts(w);
            return a;
        }

        int[][]nextIntMatSum(int h,int w) {
        	int[][]a=new int[h][w];
        	for(int i=0;i<h;i++)a[i]=nextIntSum(w);
    		for(int i=1;i<h;i++)for(int j=0;j<w;j++)a[i][j]+=a[i-1][j];
        	return a;
        }

        long[]nextlongs(int n){
            long[]a=new long[n];
            for(int i=0;i<n;i++){a[i]=nextLong();sum+=a[i];
            	if(high<a[i])high=a[i];if(low>a[i])low=a[i];}
            return a;
        }

        Long[]nextLongs(int n){
            Long[]a=new Long[n];
            for(int i=0;i<n;i++){a[i]=nextLong();sum+=a[i];
            	if(high<a[i])high=a[i];if(low>a[i])low=a[i];}
            return a;
        }

        long[]nextSortedlongs(int n){
        	long[]a=nextlongs(n);Arrays.sort(a);return a;
        }

        Long[]nextSortedLongs(int n){
        	Long[]a=nextLongs(n);Arrays.sort(a);return a;
        }

        long[]nextlongSum(int n){
        	long[]a=new long[n];a[0]=nextLong();
        	for(int i=1;i<n;i++)a[i]=nextLong()+a[i-1];
            return a;
        }

        long[]nextSortedlongSum(int n){
        	long[]a=nextSortedlongs(n);
        	for(int i=1;i<n;i++)a[i]+=a[i-1];
        	return a;
        }

        long[][]nextlongMat(int h,int w){
            long[][]a=new long[h][w];
            for(int i=0;i<h;i++)a[i]=nextlongs(w);
            return a;
        }

        long[][]nextlongMatSum(int h,int w){
        	long[][]a=new long[h][w];
        	for(int i=0;i<h;i++)a[i]=nextlongSum(w);
    		for (int i=1;i<h;i++)for(int j=0;j<w;j++)a[i][j]+=a[i-1][j];
        	return a;
        }

    }
	@SuppressWarnings("unused")
	private static class FastPrinter {
        private final PrintWriter out=new PrintWriter(System.out);

        void println(Object o){out.println(o);}

        void println(String s){out.println(s);}

        void println(boolean f){out.println(f);}

        void println(char c){out.println(c);}

        void println(int a){out.println(a);}

        void println(long a){out.println(a);}

        void println(double a){out.println(a);}

        void println(Object...o){for(Object x:o)out.println(x);}

        void println(char[]c){for(char x:c)out.println(x);}

        void println(int[]a){for(int x:a)out.println(x);}

        void println(long[]a){for(long x:a)out.println(x);}

        void println(Object[][]o){for(Object[]x:o)print(x);}

        void println(char[][]c){for(char[]d:c)print(d);}

        void println(int[][]a){for(int[]b:a)print(b);}

        void println(long[][]a){for(long[]b:a)print(b);}

        void print(Object o){out.print(o);}

        void print(String s){out.print(s);}

        void print(boolean f){out.print(f);}

        void print(char c){out.print(c);}

        void print(int a){out.print(a);}

        void print(long a){out.print(a);}

        void print(double a){out.print(a);}

        void print(Object...o){
        	StringJoiner sj=new StringJoiner(" ");
            for(Object x: o)sj.add(String.valueOf(x));
            out.println(sj);
        }

        void print(char[]c){
        	StringJoiner sj=new StringJoiner(" ");
            for(char x:c)sj.add(String.valueOf(x));
            out.println(sj);
        }

        void print(int[]a){
            StringJoiner sj=new StringJoiner(" ");
            for(int x:a)sj.add(Integer.toString(x));
            out.println(sj);
        }

        void print(long[]a){
            StringJoiner sj=new StringJoiner(" ");
            for(long x:a)sj.add(Long.toString(x));
            out.println(sj);
        }

        void printf(String frmt,Object...args){out.printf(frmt,args);}

        void printf(Locale l,String frmt,Object...args){out.printf(l,frmt,args);}

        void flush(){out.flush();}

        void close(){out.close();}

	}        
}
0