結果

問題 No.999 てん vs. ほむ
ユーザー bluemeganebluemegane
提出日時 2020-02-29 09:07:59
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 109,892 KB
実行使用メモリ 45,376 KB
最終ジャッジ日時 2024-04-21 21:27:59
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
17,792 KB
testcase_01 AC 22 ms
17,920 KB
testcase_02 AC 23 ms
18,048 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 77 ms
34,688 KB
testcase_18 AC 75 ms
34,304 KB
testcase_19 AC 77 ms
34,688 KB
testcase_20 AC 79 ms
34,688 KB
testcase_21 AC 99 ms
41,856 KB
testcase_22 AC 97 ms
41,600 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 int getAns(int n, int[] a)
    {
        var ans = 0;
        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