結果
| 問題 | 
                            No.5 数字のブロック
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-01-27 16:51:41 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 750 bytes | 
| コンパイル時間 | 3,018 ms | 
| コンパイル使用メモリ | 104,576 KB | 
| 実行使用メモリ | 20,224 KB | 
| 最終ジャッジ日時 | 2024-12-29 06:52:43 | 
| 合計ジャッジ時間 | 5,102 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 WA * 4 RE * 10 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
namespace prob005
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int s = 0;
            bool f = false;
            Array.Sort(c);
            for (int i = 1; i < b+1; i++)
            {
                s += c[i];
                if (s>a)
                {
                    Console.WriteLine(i);
                    f = true;
                    break;
                }
            }
            if (!f)
            {
                Console.WriteLine(b);
            }
        }
    }
}