結果

問題 No.999 てん vs. ほむ
ユーザー bluemeganebluemegane
提出日時 2020-02-29 09:09:56
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 2,530 ms
コンパイル使用メモリ 104,320 KB
実行使用メモリ 42,368 KB
最終ジャッジ日時 2024-04-21 21:28:22
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
17,920 KB
testcase_01 AC 26 ms
17,664 KB
testcase_02 AC 25 ms
17,920 KB
testcase_03 AC 25 ms
17,920 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 31 ms
18,048 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 96 ms
34,688 KB
testcase_18 AC 95 ms
34,432 KB
testcase_19 AC 94 ms
34,688 KB
testcase_20 AC 96 ms
34,560 KB
testcase_21 AC 122 ms
41,856 KB
testcase_22 AC 120 ms
41,344 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var b = new int[n];
        for (int i = 0; i < n; i++)
            b[i] = a[2 * i] - a[2 * i + 1];
        Console.WriteLine(getAns(n, b));
    }
    static long getAns(int n, int[] a)
    {
        var ans = 0L;
        var L = 0;
        var r = n - 1;
        for (int i = 0; i < n; i++)
        {
            if (a[L] >= -a[r]) { ans += a[L]; L++; }
            else { ans += -a[r]; r--; }
        }
        return ans;
    }
}

0