結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー bluemeganebluemegane
提出日時 2021-10-29 22:31:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,263 bytes
コンパイル時間 2,737 ms
コンパイル使用メモリ 104,704 KB
実行使用メモリ 18,560 KB
最終ジャッジ日時 2024-04-16 15:21:47
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
17,792 KB
testcase_01 AC 31 ms
18,432 KB
testcase_02 AC 35 ms
18,304 KB
testcase_03 AC 35 ms
18,304 KB
testcase_04 AC 35 ms
18,560 KB
testcase_05 AC 34 ms
18,432 KB
testcase_06 AC 32 ms
18,432 KB
testcase_07 AC 33 ms
18,432 KB
testcase_08 AC 36 ms
18,560 KB
testcase_09 AC 32 ms
18,560 KB
testcase_10 AC 28 ms
17,920 KB
testcase_11 AC 36 ms
18,304 KB
testcase_12 AC 37 ms
18,176 KB
testcase_13 AC 37 ms
18,432 KB
testcase_14 AC 36 ms
18,560 KB
testcase_15 AC 36 ms
18,304 KB
testcase_16 AC 36 ms
18,304 KB
testcase_17 AC 36 ms
18,432 KB
testcase_18 AC 36 ms
18,304 KB
testcase_19 AC 37 ms
18,560 KB
testcase_20 AC 38 ms
18,560 KB
testcase_21 AC 27 ms
17,792 KB
testcase_22 AC 25 ms
17,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var x = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var y = Array.ConvertAll(line, int.Parse);
        getAns(m, x, y);
    }
    static void getAns(int m, int[] x, int[] y)
    {
        Array.Sort(y);
        foreach (var a in x)
        {
            var p = LowerBound<int>(y, a);
            if (p == m) Console.WriteLine("Infinity");
            else Console.WriteLine(y[p] - a);
        }
    }
    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}
0