結果

問題 No.2217 Suffix+
ユーザー kakel-san
提出日時 2023-08-26 19:44:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 105,088 KB
実行使用メモリ 35,968 KB
最終ジャッジ日時 2024-12-25 21:22:23
合計ジャッジ時間 8,249 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var a = NList;
        var ok = 0L;
        var ng = 1_000_000_000_000_000;
        while (ng - ok > 1)
        {
            var mid = (ok + ng) / 2;
            var cnt = 0L;
            var add = 0L;
            for (var i = 0; i < n; ++i)
            {
                if (a[i] + add < mid)
                {
                    var sub = (mid - add - a[i] + i) / (i + 1);
                    cnt += sub;
                    add += sub * (i + 1);
                }
            }
            if (cnt > k) ng = mid;
            else ok = mid;
        }
        WriteLine(ok);
    }
}
0