結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
fujic
|
| 提出日時 | 2017-12-25 21:48:16 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 902 bytes |
| コンパイル時間 | 1,053 ms |
| コンパイル使用メモリ | 115,944 KB |
| 実行使用メモリ | 28,632 KB |
| 最終ジャッジ日時 | 2024-12-17 20:14:33 |
| 合計ジャッジ時間 | 3,242 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 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.Collections.Generic;
using System.Linq;
namespace BlocksIn
{
class MainClass
{
public static void Main(string[] args)
{
int m = 0;
int n = 0;
string M = Console.ReadLine();
string N = Console.ReadLine();
bool flgM = int.TryParse(M, out m);
bool flgN = int.TryParse(N, out n);
if (!flgM || m == 0)
{
Console.WriteLine("Erorr WidthSize");
return;
}
if (!flgN || n == 0)
{
Console.WriteLine("Erorr WidthSize");
return;
}
List<int> blocks = new List<int>();
string Blocks = Console.ReadLine();
string[] blks = Blocks.Split(new char[] { ' ' });
for (int i = 0; i < n; i++)
{
blocks.Add(int.Parse(blks[i]));
}
int all = 0;
List<int> res = blocks.OrderBy(x => x).Where(x => (all += x) < m).ToList();
foreach (int a in res)
{
Console.Write(a + " ");
}
Console.Write("\n");
}
}
}
fujic