結果

問題 No.5 数字のブロック
ユーザー #ラス+#ラス+
提出日時 2019-11-12 07:48:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 1,242 bytes
コンパイル時間 3,691 ms
コンパイル使用メモリ 112,204 KB
実行使用メモリ 25,348 KB
最終ジャッジ日時 2023-10-17 11:50:11
合計ジャッジ時間 5,433 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,132 KB
testcase_01 AC 28 ms
24,136 KB
testcase_02 AC 26 ms
24,040 KB
testcase_03 AC 36 ms
25,016 KB
testcase_04 AC 35 ms
24,908 KB
testcase_05 AC 36 ms
25,096 KB
testcase_06 AC 35 ms
24,956 KB
testcase_07 AC 35 ms
24,920 KB
testcase_08 AC 36 ms
24,996 KB
testcase_09 AC 34 ms
24,684 KB
testcase_10 AC 37 ms
25,264 KB
testcase_11 AC 35 ms
24,912 KB
testcase_12 AC 36 ms
25,020 KB
testcase_13 AC 37 ms
25,092 KB
testcase_14 AC 28 ms
24,152 KB
testcase_15 AC 33 ms
24,500 KB
testcase_16 AC 36 ms
25,112 KB
testcase_17 AC 37 ms
25,312 KB
testcase_18 AC 37 ms
25,288 KB
testcase_19 AC 38 ms
25,348 KB
testcase_20 AC 27 ms
24,132 KB
testcase_21 AC 28 ms
24,132 KB
testcase_22 AC 27 ms
24,132 KB
testcase_23 AC 28 ms
24,132 KB
testcase_24 AC 33 ms
24,500 KB
testcase_25 AC 32 ms
24,516 KB
testcase_26 AC 28 ms
24,132 KB
testcase_27 AC 27 ms
24,132 KB
testcase_28 AC 26 ms
24,040 KB
testcase_29 AC 34 ms
24,908 KB
testcase_30 AC 33 ms
24,684 KB
testcase_31 AC 26 ms
24,040 KB
testcase_32 AC 26 ms
24,040 KB
testcase_33 AC 26 ms
24,040 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.IO;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
class Start{
  static void Solve(){
    var l=Rint();
    var n=Rint();
    var w=new List<int>();
    for(int i=0;i<n;i++)w.Add(Rint());
    w.Sort();
    var ans=0;
    var W=0;
    for(int i=0;i<n;i++)
      if(W+w[i]<=l){
        ans++;
        W+=w[i];
      }
    WriteLine(ans);
  }
  static void Main(){
    readcount=0;
    read=In.ReadToEnd().Split(' ','\n');
    var sw=new StreamWriter(OpenStandardOutput()){AutoFlush=false};
    SetOut(sw);
    Solve();
    Out.Flush();
  }
  const long MOD=1000000007L;
  static void Swap<T>(ref T a,ref T b){T c=a;a=b;b=c;}
  static string Read()=>read[readcount++];
  static int Rint()=>int.Parse(read[readcount++]);
  static long Rlong()=>long.Parse(read[readcount++]);
  static double Rdouble()=>double.Parse(read[readcount++]);
  static char Rchar()=>read[readcount++][0];
  static string[] read;static int readcount;
}
class Pair<T1,T2>:IComparable<Pair<T1,T2>>where T1:IComparable<T1>where T2:IComparable<T2>{
  public T1 F;public T2 S;
  public Pair(T1 f,T2 s){F=f;S=s;}
  public int CompareTo(Pair<T1,T2> p)=>F.CompareTo(p.F)!=0?F.CompareTo(p.F):S.CompareTo(p.S);
}
0