結果

問題 No.1268 Fruit Rush 2
ユーザー keymoonkeymoon
提出日時 2020-10-23 22:38:27
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 949 bytes
コンパイル時間 3,100 ms
コンパイル使用メモリ 107,168 KB
実行使用メモリ 61,880 KB
最終ジャッジ日時 2023-09-28 16:46:57
合計ジャッジ時間 9,963 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
23,852 KB
testcase_01 AC 74 ms
21,820 KB
testcase_02 AC 70 ms
23,804 KB
testcase_03 AC 67 ms
21,760 KB
testcase_04 AC 68 ms
23,800 KB
testcase_05 AC 67 ms
21,848 KB
testcase_06 AC 67 ms
21,800 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 67 ms
21,736 KB
testcase_10 AC 68 ms
19,848 KB
testcase_11 AC 69 ms
21,724 KB
testcase_12 RE -
testcase_13 AC 68 ms
19,884 KB
testcase_14 AC 69 ms
21,828 KB
testcase_15 RE -
testcase_16 AC 251 ms
47,972 KB
testcase_17 AC 225 ms
45,072 KB
testcase_18 AC 236 ms
45,340 KB
testcase_19 AC 233 ms
48,232 KB
testcase_20 AC 231 ms
46,328 KB
testcase_21 AC 233 ms
46,180 KB
testcase_22 AC 252 ms
51,044 KB
testcase_23 AC 249 ms
51,020 KB
testcase_24 AC 235 ms
47,172 KB
testcase_25 AC 229 ms
45,224 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 301 ms
50,600 KB
testcase_32 AC 299 ms
53,712 KB
testcase_33 RE -
testcase_34 AC 271 ms
61,880 KB
testcase_35 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(int.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