提出 #71301126


ソースコード 拡げる

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] C = new int[M+1];
        double[] B = new double[M+1];
        for (int i = 0; i < N; i++) {
            int ind = sc.nextInt();
            C[ind]++;
            B[ind] += sc.nextInt();
        }

        for (int i = 1; i <= M; i++) {
            System.out.println(B[i]/C[i]);
        }

        out.flush();
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return buflen > 0;
            }
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return !hasNextByte();
        }

        public String next() {
            if (hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

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

提出情報

提出日時
問題 B - Bird Watching
ユーザ AAH_tomato
言語 Java24 (OpenJDK 24.0.2)
得点 200
コード長 3204 Byte
結果 AC
実行時間 46 ms
メモリ 38304 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 1
AC × 24
セット名 テストケース
Sample sample_01.txt
All sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 46 ms 38212 KiB
test_01.txt AC 38 ms 38064 KiB
test_02.txt AC 39 ms 38304 KiB
test_03.txt AC 39 ms 38300 KiB
test_04.txt AC 39 ms 37756 KiB
test_05.txt AC 41 ms 38144 KiB
test_06.txt AC 40 ms 38004 KiB
test_07.txt AC 41 ms 37912 KiB
test_08.txt AC 39 ms 38196 KiB
test_09.txt AC 39 ms 38096 KiB
test_10.txt AC 39 ms 37760 KiB
test_11.txt AC 39 ms 38096 KiB
test_12.txt AC 39 ms 38020 KiB
test_13.txt AC 40 ms 37952 KiB
test_14.txt AC 39 ms 38212 KiB
test_15.txt AC 39 ms 37780 KiB
test_16.txt AC 39 ms 38240 KiB
test_17.txt AC 39 ms 38116 KiB
test_18.txt AC 39 ms 38220 KiB
test_19.txt AC 39 ms 38072 KiB
test_20.txt AC 40 ms 38304 KiB
test_21.txt AC 40 ms 38224 KiB
test_22.txt AC 39 ms 37856 KiB
test_23.txt AC 38 ms 38120 KiB