結果

問題 No.1046 Fruits Rush
ユーザー boya978boya978
提出日時 2020-05-22 22:49:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 110,684 KB
実行使用メモリ 27,564 KB
最終ジャッジ日時 2024-04-15 17:59:46
合計ジャッジ時間 1,982 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
25,260 KB
testcase_01 AC 29 ms
23,220 KB
testcase_02 AC 30 ms
27,168 KB
testcase_03 AC 28 ms
25,256 KB
testcase_04 AC 28 ms
27,176 KB
testcase_05 AC 29 ms
27,304 KB
testcase_06 AC 28 ms
23,088 KB
testcase_07 AC 28 ms
25,384 KB
testcase_08 AC 29 ms
25,124 KB
testcase_09 AC 28 ms
23,092 KB
testcase_10 AC 29 ms
25,380 KB
testcase_11 AC 28 ms
25,264 KB
testcase_12 AC 28 ms
25,136 KB
testcase_13 AC 28 ms
27,564 KB
testcase_14 AC 28 ms
27,184 KB
testcase_15 AC 29 ms
25,392 KB
testcase_16 AC 28 ms
25,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
public class Program{
    public static void Main(){
        
            var nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int fruits = nums[0],  n=nums[1];
            nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(nums);
            Array.Reverse(nums);
            int sum=0;
            
            for(int i=0;i<n;i++)
            {   
                if(i==0 && nums[i]<1){
                    sum=nums[0];
                    break;
                }
                
                if(nums[i]<1)
                    break;
                sum += nums[i];
            }
                
            
            Console.WriteLine(sum);
        
    }
}
0