結果

問題 No.45 回転寿司
ユーザー boya978
提出日時 2021-01-13 22:07:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 4,869 ms
コンパイル使用メモリ 110,928 KB
実行使用メモリ 27,616 KB
最終ジャッジ日時 2024-11-22 18:28:40
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
public class Hello{
    public static void Main(){
        
        int n=int.Parse(Console.ReadLine());
        var V = Console.ReadLine().Split().Select(int.Parse).ToArray();
        
        var dp = new int[2];
        
        for(int i=0;i<n;i++)
        {
            var dp2 = new int[2];
            dp2[0] = dp.Max();
            dp2[1] = dp[0] + V[i];
            Array.Copy(dp2,dp,2);
        }
        
        Console.WriteLine(dp.Max());
    }
}
0