結果
問題 | No.1268 Fruit Rush 2 |
ユーザー |
![]() |
提出日時 | 2020-10-23 22:38:53 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 304 ms / 2,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 1,237 ms |
コンパイル使用メモリ | 112,292 KB |
実行使用メモリ | 62,228 KB |
最終ジャッジ日時 | 2024-07-21 11:29:54 |
合計ジャッジ時間 | 8,413 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);}}