結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
No
|
| 提出日時 | 2018-01-26 02:49:08 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 2,000 ms |
| コード長 | 806 bytes |
| コンパイル時間 | 1,167 ms |
| コンパイル使用メモリ | 107,136 KB |
| 実行使用メモリ | 26,368 KB |
| 最終ジャッジ日時 | 2024-12-26 16:22:44 |
| 合計ジャッジ時間 | 3,474 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
コンパイルメッセージ
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 y
{
class Program
{
static void Main(string[] args)
{
string[] ss = Console.ReadLine().Split();
int n = int.Parse(ss[0]);
int k = int.Parse(ss[1]);
int[] a = new int[n];
for (int i = 0; i < n; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
var li = new List<int>();
li.Add(0);
for (int i = 0; i < n; i++)
{
int c = li.Count;
for (int j = 0; j < c; j++)
{
li.Add(li[j] + a[i]);
}
}
Console.WriteLine(li.Where(x => x <= k).Max());
}
}
}
No