結果

問題 No.2601 Very Poor
ユーザー heno239heno239
提出日時 2024-02-05 17:35:35
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 8,803 ms
コンパイル使用メモリ 158,604 KB
実行使用メモリ 180,624 KB
最終ジャッジ日時 2024-03-20 19:54:22
合計ジャッジ時間 11,634 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
32,548 KB
testcase_01 AC 75 ms
32,548 KB
testcase_02 AC 76 ms
32,548 KB
testcase_03 AC 76 ms
32,548 KB
testcase_04 AC 76 ms
32,548 KB
testcase_05 AC 78 ms
32,804 KB
testcase_06 AC 78 ms
32,804 KB
testcase_07 AC 78 ms
32,804 KB
testcase_08 AC 78 ms
32,804 KB
testcase_09 AC 77 ms
32,804 KB
testcase_10 AC 77 ms
32,804 KB
testcase_11 AC 77 ms
32,804 KB
testcase_12 AC 77 ms
32,804 KB
testcase_13 AC 78 ms
32,804 KB
testcase_14 AC 77 ms
32,804 KB
testcase_15 AC 110 ms
48,088 KB
testcase_16 AC 110 ms
48,088 KB
testcase_17 AC 110 ms
48,088 KB
testcase_18 AC 111 ms
48,088 KB
testcase_19 AC 111 ms
48,088 KB
testcase_20 AC 110 ms
48,088 KB
testcase_21 AC 111 ms
48,088 KB
testcase_22 AC 110 ms
48,088 KB
testcase_23 AC 111 ms
48,088 KB
testcase_24 AC 110 ms
48,088 KB
testcase_25 AC 110 ms
48,088 KB
testcase_26 AC 111 ms
48,088 KB
testcase_27 AC 112 ms
48,088 KB
testcase_28 AC 111 ms
48,088 KB
testcase_29 AC 112 ms
48,088 KB
testcase_30 AC 111 ms
48,088 KB
testcase_31 AC 111 ms
48,088 KB
testcase_32 AC 111 ms
48,088 KB
testcase_33 AC 111 ms
48,088 KB
testcase_34 AC 111 ms
48,084 KB
testcase_35 AC 77 ms
32,804 KB
testcase_36 AC 78 ms
180,624 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System.Collections;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal class Program
{
    private const long mod = 998244353;

    
    public static void Main(string[] args)
    {
        int[] line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int n = line[0];
        int x = line[1];
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        long sum = 0;
        for (int i = 0; i < n; i++) sum += a[i];
        if (sum <= x)
        {
            Console.WriteLine(sum);
            return;
        }

        int r = 0;
        sum = 0;
        long ans = 0;
        for (int l = 0; l < n; l++)
        {
            while (sum + a[r] <= x)
            {
                sum += a[r];
                r++;
                if (r == n) r = 0;
            }
            //Console.WriteLine("{0},{1}",l,sum);
            ans = Math.Max(ans, sum);
            sum -= a[l];
        }
        Console.WriteLine(ans);
    }

    public static List<int> mkar(int n, int val)
    {
        List<int> res = new List<int>(n);
        for(int i=0;i<n;i++)res.Add(val);
        return res;
    }
}
0