結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
Rake
|
| 提出日時 | 2020-01-24 07:51:00 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 5,000 ms |
| コード長 | 2,598 bytes |
| コンパイル時間 | 1,096 ms |
| コンパイル使用メモリ | 118,888 KB |
| 実行使用メモリ | 27,236 KB |
| 最終ジャッジ日時 | 2024-09-13 20:14:22 |
| 合計ジャッジ時間 | 3,178 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);}
}
Rake