結果

問題 No.1686 Geschenkt
ユーザー bluemeganebluemegane
提出日時 2021-09-24 22:08:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 65,508 KB
実行使用メモリ 22,828 KB
最終ジャッジ日時 2023-09-18 21:26:52
合計ジャッジ時間 2,395 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,572 KB
testcase_01 AC 57 ms
22,720 KB
testcase_02 AC 58 ms
20,812 KB
testcase_03 AC 56 ms
20,652 KB
testcase_04 AC 57 ms
22,704 KB
testcase_05 AC 57 ms
22,768 KB
testcase_06 AC 57 ms
22,692 KB
testcase_07 AC 57 ms
20,676 KB
testcase_08 AC 57 ms
22,828 KB
testcase_09 AC 56 ms
20,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var t = new bool[40];
        for (int i = 0; i < n; i++) t[a[i]] = true;
        var ans = 0;
        for (int i = 1; i < 40; i++)
        {
            if (t[i] && !t[i - 1]) ans += i;
        }
        Console.WriteLine(ans);
    }
}
0