結果

問題 No.5 数字のブロック
ユーザー Salvia0911Salvia0911
提出日時 2023-11-05 20:33:20
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 2,896 bytes
コンパイル時間 7,704 ms
コンパイル使用メモリ 158,428 KB
実行使用メモリ 176,432 KB
最終ジャッジ日時 2023-11-05 20:33:35
合計ジャッジ時間 11,615 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
31,076 KB
testcase_01 AC 61 ms
31,080 KB
testcase_02 AC 58 ms
30,800 KB
testcase_03 AC 78 ms
32,076 KB
testcase_04 AC 72 ms
31,932 KB
testcase_05 AC 82 ms
32,224 KB
testcase_06 AC 74 ms
31,712 KB
testcase_07 AC 72 ms
31,644 KB
testcase_08 AC 77 ms
31,776 KB
testcase_09 AC 67 ms
31,440 KB
testcase_10 AC 82 ms
32,304 KB
testcase_11 AC 74 ms
31,624 KB
testcase_12 AC 77 ms
32,096 KB
testcase_13 AC 80 ms
32,208 KB
testcase_14 AC 62 ms
31,088 KB
testcase_15 AC 64 ms
31,256 KB
testcase_16 AC 82 ms
32,228 KB
testcase_17 AC 84 ms
32,384 KB
testcase_18 AC 84 ms
32,332 KB
testcase_19 AC 86 ms
32,616 KB
testcase_20 AC 61 ms
31,072 KB
testcase_21 AC 62 ms
31,072 KB
testcase_22 AC 62 ms
31,072 KB
testcase_23 AC 62 ms
31,076 KB
testcase_24 AC 64 ms
31,252 KB
testcase_25 AC 67 ms
31,276 KB
testcase_26 AC 61 ms
31,084 KB
testcase_27 AC 62 ms
31,084 KB
testcase_28 AC 59 ms
30,804 KB
testcase_29 AC 73 ms
31,920 KB
testcase_30 AC 68 ms
31,456 KB
testcase_31 AC 58 ms
30,800 KB
testcase_32 AC 59 ms
30,800 KB
testcase_33 AC 58 ms
176,432 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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;
using System.Collections.Generic;


public class InputStrorage
{
    public long L;
    public long N;
    public long[] Array;
}

public static class InputHandler
{
    public static void ReadInput(InputStrorage input)
    {
        string[] str = Console.ReadLine().Split();
        input.L = int.Parse(str[0]);

        str = Console.ReadLine().Split();
        input.N = int.Parse(str[0]);

        str = Console.ReadLine().Split();
        input.Array = new long[input.N];
        for(int i  =0; i < input.N; i++)
        {
            input.Array[i] = long.Parse(str[i]);
        }
    }
}

namespace GeneralLibs
{
    public class Compare
    {
        public static long ReturnMax(long a, long b)
        {
            if (a > b) return a;
            else return b;
        }

        public static long ReturnMax(long[] a)
        {
            long max = long.MinValue;
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] > max) max = a[i];
            }
            return max;
        }
    }

    public class ShowValues
    {
        public static void ShowArray1D(long[] a, string str = "default")
        {
            Console.WriteLine(str);
            for (int i = 0; i < a.Length; i++)
            {
                Console.Write("{0} ", a[i]);
            }
            Console.WriteLine();
            Console.WriteLine(str);
        }

        public static void ShowValue(long a, string str = "default")
        {
            Console.WriteLine("{0} : {1}", a, str);
        }
    }
}

public class SpecificLibs
{

}

public class BinarySearch
{
    public static long ReturnLowerBoundOfTarget(long[] array, long target)
    {
        long First = 0;
        long Mid = -1;
        long Last = array.Length - 1;

        while (First <= Last)
        {
            Mid = First + (Last - First) / 2;
            if (array[Mid] <= target) First = Mid + 1;
            else Last = Mid - 1;
        }
        return Last;
    }
}

public class PrefixSum
{
    public static long[] ReturnPrefixSum1D(long[] input)
    {
        long n = input.Length;
        long[] output = new long[n + 1];
        long sum = 0;
        output[0] = 0;

        for (long i = 1; i < n + 1; i++)
        {
            sum += input[i - 1];
            output[i] = sum;
        }
        return output;
    }

    public static long ReturnSegmentValue(long[] input, long start, long end)
    {
        return input[end] - input[start - 1];
    }
}

static class No5
{
    static void Main()
    {
        InputStrorage input = new InputStrorage();
        InputHandler.ReadInput(input);

        Array.Sort(input.Array);

        long[] sum = new long[input.N + 1];
        sum = PrefixSum.ReturnPrefixSum1D(input.Array);
        
        long target = BinarySearch.ReturnLowerBoundOfTarget(sum,input.L);
        Console.WriteLine(target);
    }
}
0