結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2016-07-31 23:28:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,379 bytes |
コンパイル時間 | 777 ms |
コンパイル使用メモリ | 110,812 KB |
実行使用メモリ | 99,968 KB |
最終ジャッジ日時 | 2024-11-24 17:15:35 |
合計ジャッジ時間 | 10,840 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 >= 0; v--) { if(v == 0 || CheckList(dp[v], i)) { int val = v + V[i]; dp[val].Add(i); if (maxValue < val) maxValue = val; } } } 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; } } }