結果

問題 No.45 回転寿司
ユーザー しらゆきしらゆき
提出日時 2016-01-10 14:00:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 2,004 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 105,480 KB
実行使用メモリ 23,896 KB
最終ジャッジ日時 2023-08-27 14:30:58
合計ジャッジ時間 5,704 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
23,840 KB
testcase_01 AC 69 ms
21,864 KB
testcase_02 AC 69 ms
23,780 KB
testcase_03 AC 68 ms
21,864 KB
testcase_04 AC 68 ms
21,720 KB
testcase_05 AC 60 ms
21,604 KB
testcase_06 AC 68 ms
23,868 KB
testcase_07 AC 69 ms
21,892 KB
testcase_08 AC 68 ms
21,644 KB
testcase_09 AC 68 ms
23,780 KB
testcase_10 AC 68 ms
19,804 KB
testcase_11 AC 68 ms
23,760 KB
testcase_12 AC 69 ms
21,720 KB
testcase_13 AC 61 ms
23,748 KB
testcase_14 AC 60 ms
21,672 KB
testcase_15 AC 69 ms
23,796 KB
testcase_16 AC 68 ms
23,872 KB
testcase_17 AC 68 ms
21,652 KB
testcase_18 AC 68 ms
21,788 KB
testcase_19 AC 68 ms
21,740 KB
testcase_20 AC 61 ms
23,708 KB
testcase_21 AC 61 ms
19,660 KB
testcase_22 AC 61 ms
23,676 KB
testcase_23 AC 61 ms
21,604 KB
testcase_24 AC 60 ms
21,592 KB
testcase_25 AC 60 ms
23,588 KB
testcase_26 AC 68 ms
23,776 KB
testcase_27 AC 68 ms
19,796 KB
testcase_28 AC 69 ms
21,836 KB
testcase_29 AC 69 ms
23,896 KB
testcase_30 AC 69 ms
23,708 KB
testcase_31 AC 60 ms
21,604 KB
testcase_32 AC 61 ms
21,596 KB
testcase_33 AC 69 ms
23,828 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int n = ri();
        var v = ria();

        var dp = new int[n];
        dp[0] = v[0];
        if (n > 1) dp[1] = Math.Max(v[0], v[1]);
        for (int i = 2; i < n; i++)
        {
            dp[i] = Math.Max(dp[i - 2] + v[i], dp[i - 1]);
        }

        Console.WriteLine(dp[n - 1]);
    }

    #region Scan
    static int ri() { return int.Parse(Console.ReadLine()); }
    static long rl() { return long.Parse(Console.ReadLine()); }
    static double rd() { return double.Parse(Console.ReadLine()); }
    static string rs() { return Console.ReadLine(); }
    static int[] ria() { return Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); }
    static long[] rla() { return Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
    static double[] rda() { return Console.ReadLine().Trim().Split().Select(double.Parse).ToArray(); }
    static string[] rsa() { return Console.ReadLine().Trim().Split(); }
    static void mul(out int a, out int b) { var arr = ria(); a = arr[0]; b = arr[1]; }
    static void mul(out int a, out int b, out int c) { var arr = ria(); a = arr[0]; b = arr[1]; c = arr[2]; }
    static void mul(out int a, out int b, out int c, out int d) { var arr = ria(); a = arr[0]; b = arr[1]; c = arr[2]; d = arr[3]; }
    static void mul(out long a, out long b) { var arr = rla(); a = arr[0]; b = arr[1]; }
    static void mul(out long a, out long b, out long c) { var arr = rla(); a = arr[0]; b = arr[1]; c = arr[2]; }
    static void mul(out long a, out long b, out long c, out long d) { var arr = rla(); a = arr[0]; b = arr[1]; c = arr[2]; d = arr[3]; }
    #endregion
    #region Math
    const int mod = 1000000007;
    static bool isprime(long n)
    {
        if (n < 2) return false;
        for (long i = 2; i * i <= n; i++)
            if (n % i == 0)
                return false;
        return true;
    }

    #endregion
}
0