結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー keymoonkeymoon
提出日時 2021-01-18 11:43:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 554 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 107,648 KB
実行使用メモリ 52,632 KB
最終ジャッジ日時 2024-05-08 01:40:25
合計ジャッジ時間 22,275 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
19,200 KB
testcase_01 AC 29 ms
19,072 KB
testcase_02 AC 26 ms
19,072 KB
testcase_03 AC 28 ms
19,072 KB
testcase_04 AC 27 ms
19,072 KB
testcase_05 AC 28 ms
19,200 KB
testcase_06 AC 27 ms
19,072 KB
testcase_07 AC 27 ms
19,328 KB
testcase_08 AC 28 ms
19,200 KB
testcase_09 AC 27 ms
19,200 KB
testcase_10 AC 26 ms
19,072 KB
testcase_11 AC 28 ms
19,072 KB
testcase_12 AC 26 ms
19,328 KB
testcase_13 AC 27 ms
19,456 KB
testcase_14 AC 27 ms
19,328 KB
testcase_15 AC 27 ms
19,328 KB
testcase_16 AC 27 ms
19,072 KB
testcase_17 AC 29 ms
19,200 KB
testcase_18 AC 534 ms
51,692 KB
testcase_19 AC 515 ms
50,848 KB
testcase_20 AC 322 ms
42,368 KB
testcase_21 AC 76 ms
22,016 KB
testcase_22 AC 335 ms
43,904 KB
testcase_23 AC 56 ms
21,460 KB
testcase_24 AC 422 ms
44,956 KB
testcase_25 AC 314 ms
43,264 KB
testcase_26 AC 129 ms
26,112 KB
testcase_27 AC 61 ms
21,500 KB
testcase_28 AC 549 ms
52,364 KB
testcase_29 AC 540 ms
52,384 KB
testcase_30 AC 554 ms
52,492 KB
testcase_31 AC 519 ms
52,524 KB
testcase_32 AC 539 ms
52,508 KB
testcase_33 AC 545 ms
52,496 KB
testcase_34 AC 537 ms
52,368 KB
testcase_35 AC 546 ms
52,628 KB
testcase_36 AC 554 ms
52,376 KB
testcase_37 AC 550 ms
52,516 KB
testcase_38 AC 547 ms
52,256 KB
testcase_39 AC 535 ms
52,512 KB
testcase_40 AC 542 ms
52,500 KB
testcase_41 AC 538 ms
52,632 KB
testcase_42 AC 547 ms
52,380 KB
testcase_43 AC 29 ms
19,328 KB
testcase_44 AC 27 ms
19,200 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 = (long)-1e6;
        long invalid = (long)1e6;
        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