結果

問題 No.1046 Fruits Rush
ユーザー bluemeganebluemegane
提出日時 2020-05-09 19:00:49
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 65,560 KB
実行使用メモリ 23,764 KB
最終ジャッジ日時 2023-09-20 07:49:34
合計ジャッジ時間 3,496 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,828 KB
testcase_01 AC 60 ms
21,568 KB
testcase_02 AC 60 ms
21,544 KB
testcase_03 AC 61 ms
23,696 KB
testcase_04 AC 66 ms
21,820 KB
testcase_05 AC 60 ms
21,592 KB
testcase_06 AC 61 ms
21,592 KB
testcase_07 AC 62 ms
21,756 KB
testcase_08 AC 61 ms
21,632 KB
testcase_09 AC 64 ms
19,752 KB
testcase_10 AC 60 ms
21,644 KB
testcase_11 AC 61 ms
21,560 KB
testcase_12 AC 61 ms
21,568 KB
testcase_13 AC 61 ms
23,764 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var a = new List<int>();
         line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
        {
            var t = int.Parse(line[i]);
            if (t > 0) a.Add(t);
        }
        var acc = a.Count();
        int ans;
        if (k >= acc) ans = a.Sum();
        else ans = a.OrderByDescending(x => x).Take(k).Sum();
        Console.WriteLine(ans);
    }
}
0