結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー keymoonkeymoon
提出日時 2021-01-18 11:43:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 2,991 ms
コンパイル使用メモリ 105,352 KB
実行使用メモリ 59,196 KB
最終ジャッジ日時 2023-08-20 19:14:24
合計ジャッジ時間 26,207 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
22,100 KB
testcase_01 AC 56 ms
22,072 KB
testcase_02 AC 56 ms
22,116 KB
testcase_03 AC 57 ms
24,040 KB
testcase_04 AC 58 ms
21,968 KB
testcase_05 AC 57 ms
22,056 KB
testcase_06 AC 57 ms
22,072 KB
testcase_07 AC 57 ms
22,120 KB
testcase_08 AC 60 ms
22,096 KB
testcase_09 AC 57 ms
21,964 KB
testcase_10 AC 56 ms
19,916 KB
testcase_11 AC 59 ms
21,936 KB
testcase_12 AC 57 ms
22,072 KB
testcase_13 AC 57 ms
22,108 KB
testcase_14 AC 58 ms
20,072 KB
testcase_15 AC 57 ms
24,016 KB
testcase_16 AC 58 ms
24,080 KB
testcase_17 AC 56 ms
22,080 KB
testcase_18 AC 521 ms
54,312 KB
testcase_19 AC 501 ms
55,496 KB
testcase_20 AC 315 ms
42,912 KB
testcase_21 AC 96 ms
21,136 KB
testcase_22 AC 342 ms
48,568 KB
testcase_23 AC 88 ms
25,244 KB
testcase_24 AC 425 ms
47,560 KB
testcase_25 AC 331 ms
48,024 KB
testcase_26 AC 159 ms
27,788 KB
testcase_27 AC 88 ms
23,144 KB
testcase_28 AC 537 ms
55,156 KB
testcase_29 AC 549 ms
57,172 KB
testcase_30 AC 549 ms
55,128 KB
testcase_31 AC 527 ms
57,088 KB
testcase_32 AC 541 ms
57,100 KB
testcase_33 AC 541 ms
57,216 KB
testcase_34 AC 544 ms
57,120 KB
testcase_35 AC 543 ms
57,192 KB
testcase_36 AC 546 ms
57,080 KB
testcase_37 AC 544 ms
55,124 KB
testcase_38 AC 546 ms
59,196 KB
testcase_39 AC 545 ms
57,208 KB
testcase_40 AC 550 ms
55,240 KB
testcase_41 AC 557 ms
55,016 KB
testcase_42 AC 537 ms
57,112 KB
testcase_43 AC 57 ms
24,016 KB
testcase_44 AC 56 ms
19,996 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