結果

問題 No.1268 Fruit Rush 2
ユーザー keymoonkeymoon
提出日時 2020-10-23 22:38:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 2,834 ms
コンパイル使用メモリ 108,660 KB
実行使用メモリ 67,648 KB
最終ジャッジ日時 2023-09-28 16:48:00
合計ジャッジ時間 11,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
22,036 KB
testcase_01 AC 71 ms
21,960 KB
testcase_02 AC 72 ms
24,024 KB
testcase_03 AC 70 ms
21,948 KB
testcase_04 AC 70 ms
24,004 KB
testcase_05 AC 69 ms
22,020 KB
testcase_06 AC 69 ms
21,932 KB
testcase_07 AC 70 ms
24,048 KB
testcase_08 AC 68 ms
21,960 KB
testcase_09 AC 72 ms
22,064 KB
testcase_10 AC 71 ms
22,064 KB
testcase_11 AC 71 ms
21,964 KB
testcase_12 AC 70 ms
21,888 KB
testcase_13 AC 71 ms
22,020 KB
testcase_14 AC 70 ms
22,124 KB
testcase_15 AC 70 ms
22,076 KB
testcase_16 AC 252 ms
50,504 KB
testcase_17 AC 229 ms
49,856 KB
testcase_18 AC 239 ms
49,220 KB
testcase_19 AC 237 ms
51,240 KB
testcase_20 AC 235 ms
47,192 KB
testcase_21 AC 234 ms
47,900 KB
testcase_22 AC 251 ms
52,536 KB
testcase_23 AC 252 ms
52,532 KB
testcase_24 AC 236 ms
46,056 KB
testcase_25 AC 235 ms
51,088 KB
testcase_26 AC 339 ms
62,440 KB
testcase_27 AC 339 ms
63,668 KB
testcase_28 AC 346 ms
61,156 KB
testcase_29 AC 342 ms
63,308 KB
testcase_30 AC 339 ms
62,360 KB
testcase_31 AC 303 ms
55,964 KB
testcase_32 AC 300 ms
56,916 KB
testcase_33 AC 320 ms
60,572 KB
testcase_34 AC 273 ms
64,640 KB
testcase_35 AC 341 ms
67,648 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.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
        Dictionary<long, long> ways = new Dictionary<long, long>();
        long res = 0;
        foreach (var item in a)
        {
            //次の数字の作り方
            if (!ways.ContainsKey(item)) ways[item] = 0;
            if (ways.ContainsKey(item - 1))
            {
                ways[item + 1] = ways[item - 1];
                res += ways[item - 1];
            }
            ways[item]++;
            res++;
        }
        Console.WriteLine(res);
    }
}
0