結果

問題 No.5 数字のブロック
ユーザー yutakahan
提出日時 2017-12-06 09:17:45
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 882 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 108,300 KB
実行使用メモリ 26,928 KB
最終ジャッジ日時 2024-11-29 00:52:11
合計ジャッジ時間 5,994 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 RE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
public class Hello{
    static void Ascsort(int[] a){
        for(int i = 0;i < a.Length - 1;i++){
            for(int j = i + 1;j < a.Length;j++){
                if(a[i] > a[j]){
                    int temp;
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
        }
    }
    public static void Main(){
        int L = int.Parse(Console.ReadLine());
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] block = new int[N];
        for(int x = 0;x < N;x++){
            block[x] = int.Parse(input[x]);
        }
        
        Ascsort(block);
        
        int count = 0;
        while(L - block[count] >= 0){
            L -= block[count];
            count++;
        }
        Console.WriteLine(count);
    }
}
0