結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-11-07 02:06:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 3,067 bytes
コンパイル時間 2,768 ms
コンパイル使用メモリ 84,980 KB
実行使用メモリ 53,928 KB
最終ジャッジ日時 2024-04-25 14:55:42
合計ジャッジ時間 6,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
51,240 KB
testcase_01 AC 87 ms
51,740 KB
testcase_02 AC 124 ms
53,136 KB
testcase_03 AC 124 ms
53,364 KB
testcase_04 AC 121 ms
53,264 KB
testcase_05 AC 97 ms
51,824 KB
testcase_06 AC 78 ms
51,564 KB
testcase_07 AC 83 ms
51,708 KB
testcase_08 AC 128 ms
53,760 KB
testcase_09 AC 89 ms
51,944 KB
testcase_10 AC 73 ms
51,072 KB
testcase_11 AC 131 ms
53,860 KB
testcase_12 AC 131 ms
53,612 KB
testcase_13 AC 136 ms
53,908 KB
testcase_14 AC 125 ms
53,736 KB
testcase_15 AC 125 ms
53,876 KB
testcase_16 AC 135 ms
53,896 KB
testcase_17 AC 133 ms
53,840 KB
testcase_18 AC 131 ms
53,928 KB
testcase_19 AC 135 ms
53,628 KB
testcase_20 AC 136 ms
53,860 KB
testcase_21 AC 67 ms
50,812 KB
testcase_22 AC 68 ms
50,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.TreeSet;
import java.util.regex.Pattern;

public class Main {
    public void exec() {
        int n = stdin.nextInt();
        int m = stdin.nextInt();
        
        int[] x = new int[n];
        TreeSet<Integer> y = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            x[i] = stdin.nextInt();
        }
        for (int i = 0; i < m; i++) {
            y.add(stdin.nextInt());
        }
        
        for (int i = 0; i < n; i++) {
            Integer pos = y.ceiling(x[i]);
            if (pos == null) {
                stdout.println("Infinity");
            } else {
                stdout.println(pos-x[i]);
            }
        }
    }

    private static final Stdin stdin = new Stdin(System.in);
    private static final Stdout stdout = new Stdout(System.out);

    public static void main(String[] args) {
        try {
            new Main().exec();
        } finally {
            stdout.flush();
        }
    }

    public static class Stdin {
        private Deque<String> queue;
        private BufferedReader in;
        private Pattern space;

        public Stdin(InputStream in) {
            this.queue = new ArrayDeque<>();
            this.in = new BufferedReader(new InputStreamReader(in));
            this.space = Pattern.compile(" ");
        }

        public String nextString() {
            if (queue.isEmpty()) {
                try {
                    String line = in.readLine();
                    if (line == null) {
                        throw new EOFException();
                    }
                    space.splitAsStream(line).forEach(this.queue::addLast);
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return queue.removeFirst();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

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

        public long nextLong() {
            return Long.parseLong(nextString());
        }
        
        public BigInteger nextBigInteger() {
            return new BigInteger(nextString());
        }
    }

    public static class Stdout {
        private PrintWriter stdout;

        public Stdout(PrintStream stdout) {
            this.stdout =  new PrintWriter(stdout, false);
        }

        public void println(Object ... objs) {
            for (int i = 0, len = objs.length; i < len; i++) {
                stdout.print(objs[i]);
                if (i != len-1) stdout.print(' ');
            }
            stdout.println();
        }

        public void flush() {
            stdout.flush();
        }
    }
}
0