結果

問題 No.5 数字のブロック
ユーザー RakeRake
提出日時 2020-01-24 07:49:16
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,580 bytes
コンパイル時間 2,952 ms
コンパイル使用メモリ 119,272 KB
実行使用メモリ 28,116 KB
最終ジャッジ日時 2024-09-13 20:14:16
合計ジャッジ時間 4,747 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
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;
      }
    }
  }
  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