結果

問題 No.5 数字のブロック
ユーザー RakeRake
提出日時 2020-01-24 07:51:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 2,598 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 64,520 KB
実行使用メモリ 23,544 KB
最終ジャッジ日時 2023-10-11 21:21:41
合計ジャッジ時間 4,648 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,660 KB
testcase_01 AC 59 ms
22,744 KB
testcase_02 AC 58 ms
20,776 KB
testcase_03 AC 70 ms
21,072 KB
testcase_04 AC 69 ms
21,224 KB
testcase_05 AC 72 ms
21,484 KB
testcase_06 AC 70 ms
21,268 KB
testcase_07 AC 70 ms
21,376 KB
testcase_08 AC 72 ms
21,292 KB
testcase_09 AC 68 ms
23,044 KB
testcase_10 AC 71 ms
21,688 KB
testcase_11 AC 69 ms
21,220 KB
testcase_12 AC 70 ms
23,200 KB
testcase_13 AC 71 ms
23,544 KB
testcase_14 AC 61 ms
20,644 KB
testcase_15 AC 66 ms
20,804 KB
testcase_16 AC 72 ms
21,596 KB
testcase_17 AC 72 ms
21,628 KB
testcase_18 AC 72 ms
21,764 KB
testcase_19 AC 72 ms
21,568 KB
testcase_20 AC 58 ms
20,780 KB
testcase_21 AC 60 ms
20,816 KB
testcase_22 AC 58 ms
20,856 KB
testcase_23 AC 59 ms
20,836 KB
testcase_24 AC 68 ms
22,984 KB
testcase_25 AC 66 ms
20,888 KB
testcase_26 AC 59 ms
22,792 KB
testcase_27 AC 59 ms
20,600 KB
testcase_28 AC 57 ms
20,660 KB
testcase_29 AC 68 ms
21,236 KB
testcase_30 AC 67 ms
23,216 KB
testcase_31 AC 57 ms
22,732 KB
testcase_32 AC 58 ms
22,732 KB
testcase_33 AC 58 ms
20,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.IO;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using str=System.String;
using dbl=System.Double;
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 sum=0;
    for(int i=0;i<N;i++){
      sum+=W[i];
      if(sum>L){
        WriteLine(i);
        return;
      }
    }
    WriteLine(N);
  }
  static void Main(){
    READ=In.ReadToEnd().Split(' ','\n');
    SetOut(new StreamWriter(OpenStandardOutput()){AutoFlush=false});
    Solve();
    Out.Flush();
  }
  const int MAX=2147483647;
  const dbl MIN=0.0000000001;
  const long MOD=1000000007L;
  const str LF="\n";
  static str[] READ;static int RCNT;
  static str Rstr=>READ[RCNT++];
  static int Rint=>int.Parse(Rstr);
  static long Rlong=>long.Parse(Rstr);
  static dbl Rdbl=>dbl.Parse(Rstr);
  static char Rchar=>Rstr[0];
  static void Swap<T>(ref T a,ref T b){T c=a;a=b;b=c;}
  static void WriteArray<T>(T[] t){
    if(t.Length==0)Write(LF);
    else{
      Write(t[0]);
      for(int i=1;i<t.Length;i++)Write(" "+t[i]);
      Write(LF);
    }
  }
  static void WriteList<T>(ref List<T> t){
    if(t.Count==0)Write(LF);
    else{
      Write(t[0]);
      for(int i=1;i<t.Count;i++)Write(" "+t[i]);
      Write(LF);
    }
  }
}
class Pair<T>:Pair2<T,T>
  where T:IComparable<T>
{
  public Pair(){}
  public Pair(T f,T s){F=f;S=s;}
}
class Pair2<T1,T2>:IComparable<Pair2<T1,T2>>
  where T1:IComparable<T1>
  where T2:IComparable<T2>
{
  public T1 F;public T2 S;
  public Pair2(){}
  public Pair2(T1 f,T2 s){F=f;S=s;}
  public int CompareTo(Pair2<T1,T2> p){
    if(F.CompareTo(p.F)!=0)return F.CompareTo(p.F);
    return S.CompareTo(p.S);
  }
}
class Tri<Type>:IComparable<Tri<Type>>
  where Type:IComparable<Type>
{
  public Type F,S,T;
  public Tri(Type f,Type s,Type t){F=f;S=s;T=t;}
  public int CompareTo(Tri<Type> t){
    if(F.CompareTo(t.F)!=0)return F.CompareTo(t.F);
    if(S.CompareTo(t.S)!=0)return S.CompareTo(t.S);
    return T.CompareTo(t.T);
  }
}
class Dic<Tk,Tv>:Dictionary<Tk,Tv>{
  public new Tv this[Tk k]{
    get{
      Tv v;
      if(TryGetValue(k,out v))return v;
      return base[k]=default(Tv);
    }
    set{base[k]=value;}
  }
}
class PQueue<T>:SortedSet<Pair2<T,int>>
  where T:IComparable<T>
{
  private int unique;
  public void Add(T t){Add(new Pair2<T,int>(t,unique++));}
  public T Max{get{return base.Max.F;}}
  public T Min{get{return base.Min.F;}}
  public void RemMax(){Remove(base.Max);}
  public void RemMin(){Remove(base.Min);}
}
0