結果
問題 |
No.1268 Fruit Rush 2
|
ユーザー |
|
提出日時 | 2025-02-16 20:07:35 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 252 ms / 2,000 ms |
コード長 | 951 bytes |
コンパイル時間 | 8,030 ms |
コンパイル使用メモリ | 174,688 KB |
実行使用メモリ | 275,600 KB |
最終ジャッジ日時 | 2025-02-16 20:07:52 |
合計ジャッジ時間 | 16,888 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (111 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; WriteLine(Fruit(n, a)); } static long Fruit(int n, long[] a) { var set = new HashSet<long>(a); foreach (var ai in a) set.Add(ai + 1); var sa = a.ToList(); sa.Sort(); var dic = new Dictionary<long, long>(); foreach (var i in sa) { if (dic.ContainsKey(i - 1)) { dic[i + 1] = dic[i - 1]; } if (dic.ContainsKey(i)) ++dic[i]; else dic[i] = 1; } return dic.Sum(kv => kv.Value); } }