結果
問題 | No.33 アメーバがたくさん |
ユーザー | nanophoto12 |
提出日時 | 2014-11-02 05:53:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 1,720 bytes |
コンパイル時間 | 888 ms |
コンパイル使用メモリ | 110,608 KB |
実行使用メモリ | 24,292 KB |
最終ジャッジ日時 | 2023-10-24 17:41:44 |
合計ジャッジ時間 | 1,704 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
24,268 KB |
testcase_01 | AC | 26 ms
24,280 KB |
testcase_02 | AC | 25 ms
24,268 KB |
testcase_03 | AC | 26 ms
24,280 KB |
testcase_04 | AC | 27 ms
24,280 KB |
testcase_05 | AC | 27 ms
24,280 KB |
testcase_06 | AC | 26 ms
24,280 KB |
testcase_07 | AC | 26 ms
24,284 KB |
testcase_08 | AC | 27 ms
24,292 KB |
testcase_09 | AC | 27 ms
24,292 KB |
testcase_10 | AC | 26 ms
24,272 KB |
コンパイルメッセージ
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.Generic; class Program { public static void Main(string[] args) { var firstline = Console.ReadLine().Split(' '); var n = long.Parse(firstline[0]); var d = long.Parse(firstline[1]); var t = long.Parse(firstline[2]); var secondline = Console.ReadLine().Split(' '); var minMaxDictionary = new Dictionary<long, List<Tuple<long, long>>>(); for (long i = 0; i < n; i++) { var position = long.Parse(secondline[i]); var key = (d + position % d) % d; if (minMaxDictionary.ContainsKey(key)) { minMaxDictionary[key].Add(new Tuple<long, long>(position - d * t, position + d * t)); } else { minMaxDictionary.Add(key, new List<Tuple<long, long>> { new Tuple<long, long>(position - d * t, position + d * t) }); ; } } long count = 0; foreach (var element in minMaxDictionary) { var minMaxs = element.Value; minMaxs.Sort((tuple, tuple1)=>tuple.Item1.CompareTo(tuple1.Item1)); long min = long.MaxValue; long max = long.MinValue; foreach (var minMax in minMaxs) { count += (minMax.Item2 - minMax.Item1) / d + 1; if (minMax.Item1 <= max) { count -= (max - minMax.Item1) / d + 1; } min = Math.Min(min, minMax.Item1); max = Math.Max(max, minMax.Item2); } } Console.WriteLine(count); } }