結果

問題 No.989 N×Mマス計算(K以上)
ユーザー bluemeganebluemegane
提出日時 2020-02-15 14:18:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 5,091 ms
コンパイル使用メモリ 103,308 KB
実行使用メモリ 34,060 KB
最終ジャッジ日時 2023-07-28 19:13:41
合計ジャッジ時間 5,283 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,752 KB
testcase_01 AC 58 ms
20,812 KB
testcase_02 AC 59 ms
18,760 KB
testcase_03 AC 60 ms
22,780 KB
testcase_04 AC 59 ms
18,764 KB
testcase_05 AC 60 ms
22,788 KB
testcase_06 AC 59 ms
20,916 KB
testcase_07 AC 59 ms
20,748 KB
testcase_08 AC 59 ms
20,792 KB
testcase_09 AC 59 ms
20,760 KB
testcase_10 AC 122 ms
24,956 KB
testcase_11 AC 119 ms
28,232 KB
testcase_12 AC 131 ms
26,048 KB
testcase_13 AC 96 ms
26,968 KB
testcase_14 AC 163 ms
34,060 KB
testcase_15 AC 90 ms
21,960 KB
testcase_16 AC 113 ms
26,856 KB
testcase_17 AC 94 ms
25,068 KB
testcase_18 AC 101 ms
23,388 KB
testcase_19 AC 117 ms
28,328 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 n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var k = int.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
        var op = line[0];
        var a = new int[m];
        for (int i = 0; i < m; i++) a[i] = int.Parse(line[i + 1]);
        var b = new int[n];
        for (int i = 0; i < n; i++) b[i] = int.Parse(Console.ReadLine().Trim());
        Array.Sort(b);
        var ans = 0L;
        for (int i = 0; i < m; i++)
        {
            int t;
            if (op == "+") t = k - a[i];
            else t = (a[i] + k - 1) / a[i];
            var w = LowerBound(b, t);
            ans += n - w;
        }
        Console.WriteLine(ans);

    }
    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 =>
                                   LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}

0