結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー keymoonkeymoon
提出日時 2021-01-18 11:42:28
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 914 bytes
コンパイル時間 3,870 ms
コンパイル使用メモリ 104,088 KB
実行使用メモリ 61,956 KB
最終ジャッジ日時 2023-08-20 19:12:58
合計ジャッジ時間 25,118 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
22,028 KB
testcase_01 AC 60 ms
22,056 KB
testcase_02 AC 57 ms
22,016 KB
testcase_03 AC 59 ms
24,132 KB
testcase_04 AC 57 ms
22,072 KB
testcase_05 AC 57 ms
23,992 KB
testcase_06 AC 56 ms
24,000 KB
testcase_07 AC 58 ms
22,160 KB
testcase_08 AC 58 ms
22,020 KB
testcase_09 AC 58 ms
21,928 KB
testcase_10 AC 57 ms
21,948 KB
testcase_11 AC 56 ms
22,040 KB
testcase_12 AC 56 ms
21,988 KB
testcase_13 AC 57 ms
24,040 KB
testcase_14 AC 57 ms
24,120 KB
testcase_15 AC 56 ms
23,992 KB
testcase_16 AC 59 ms
24,048 KB
testcase_17 AC 58 ms
24,104 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 111 ms
23,216 KB
testcase_22 RE -
testcase_23 AC 95 ms
23,052 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 97 ms
23,200 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 58 ms
22,084 KB
testcase_44 AC 57 ms
22,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long F(long X) => a.Zip(b, (a, b) => Abs(X - a) * b).Sum();
        long valid = int.MinValue;
        long invalid = int.MaxValue;
        while (invalid - valid > 1)
        {
            var mid = (invalid + valid) / 2;
            if (F(mid) - F(mid + 1) >= 1) valid = mid;
            else invalid = mid;
        }
        Console.WriteLine($"{invalid} {F(invalid)}");
    }
}
0