結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2016-08-01 23:03:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,476 bytes |
| コンパイル時間 | 897 ms |
| コンパイル使用メモリ | 109,448 KB |
| 実行使用メモリ | 101,908 KB |
| 最終ジャッジ日時 | 2024-11-24 17:16:22 |
| 合計ジャッジ時間 | 11,065 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 11 WA * 19 |
コンパイルメッセージ
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;
namespace KaitenZushi
{
class Program
{
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine());
int[] V = new int[N];
string[] vals = Console.ReadLine().Split(' ');
for(int i=0; i < N; i++)
{
V[i] = int.Parse(vals[i]);
}
List<int>[] dp = new List<int>[100101];
for(int i=0; i <= 100100; i++)
{
dp[i] = new List<int>();
}
int maxValue = 0;
for(int i=0; i < N; i++)
{
for(int v=10000; v >= 1; v--)
{
if(CheckList(dp[v], i))
{
int val = v + V[i];
dp[val].Add(i);
if (maxValue < val)
maxValue = val;
}
}
dp[V[i]].Add(i);
if (maxValue < V[i])
maxValue = V[i];
}
Console.WriteLine(maxValue);
}
static bool CheckList(List<int> list, int i)
{
if (list.Count == 0)
return false;
foreach(int j in list)
{
if (j != i - 1)
return true;
}
return false;
}
}
}