結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-04-03 16:53:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,628 bytes |
| コンパイル時間 | 2,090 ms |
| コンパイル使用メモリ | 114,368 KB |
| 実行使用メモリ | 71,864 KB |
| 最終ジャッジ日時 | 2024-09-24 15:14:42 |
| 合計ジャッジ時間 | 8,833 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 TLE * 1 -- * 2 |
コンパイルメッセージ
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;
using System.Text;
class Program
{
public void Proc()
{
Reader.IsDebug = false;
int[] inpt = Reader.GetInt();
int amebaCount = inpt[0];
int moveLen = inpt[1];
int maxStep = inpt[2];
inpt = Reader.GetInt();
for (int i = 0; i < inpt.Length; i++)
{
AmebaList.Add(new Ameba(inpt[i], inpt[i]));
}
for (int i = 0; i < maxStep; i++)
{
List<Ameba> nextList = new List<Ameba>();
foreach (Ameba am in AmebaList)
{
nextList.Add(am.Move(moveLen * -1));
nextList.Add(am);
nextList.Add(am.Move(moveLen));
}
nextList.Sort((a, b) =>
{
if (a.From < b.From)
{
return -1;
}
if (a.From > b.From)
{
return 1;
}
if (a.To < b.To)
{
return -1;
}
if (a.To > b.To)
{
return 1;
}
return 0;
});
for (int j = nextList.Count - 1; j >= 1; j--)
{
Ameba current = nextList[j];
Ameba before = nextList[j - 1];
if (current.From >= before.From && current.From <= before.To)
{
long newFrom = before.From;
long newTo = Math.Max(before.To, current.To);
Ameba newIns = new Ameba(newFrom, newTo);
nextList[j - 1] = newIns;
nextList.RemoveAt(j);
}
this.AmebaList = nextList;
}
}
long ans = 0;
foreach (Ameba am in this.AmebaList)
{
ans += (am.To - am.From + 1);
}
Console.WriteLine(ans.ToString("####################################################0"));
}
private List<Ameba> AmebaList = new List<Ameba>();
public class Ameba
{
public long From;
public long To;
public Ameba(long from, long to)
{
this.From = from;
this.To = to;
}
public Ameba Move(int moveLen)
{
return new Ameba(this.From + moveLen, this.To + moveLen);
}
}
public class Reader
{
public static bool IsDebug = true;
private static String PlainInput = @"
2 3 1
0 2
";
private static System.IO.StringReader Sr = null;
public static string ReadLine()
{
if (IsDebug)
{
if (Sr == null)
{
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
public static int[] GetInt(char delimiter = ' ', bool trim = false)
{
string inptStr = ReadLine();
if (trim)
{
inptStr = inptStr.Trim();
}
string[] inpt = inptStr.Split(delimiter);
int[] ret = new int[inpt.Length];
for (int i = 0; i < inpt.Length; i++)
{
ret[i] = int.Parse(inpt[i]);
}
return ret;
}
}
static void Main()
{
Program prg = new Program();
prg.Proc();
}
}
14番