結果
問題 | No.999 てん vs. ほむ |
ユーザー |
![]() |
提出日時 | 2020-09-11 09:35:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 1,179 ms |
コンパイル使用メモリ | 111,900 KB |
実行使用メモリ | 47,280 KB |
最終ジャッジ日時 | 2024-12-25 04:06:29 |
合計ジャッジ時間 | 5,051 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math; 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); getAns(n, a); } static void getAns(int n, int[] a) { var pL = 0; var pr = 2 * n - 1; var h = 0L; var t = 0L; while (pr - pL > 1) { if (a[pL] - a[pL + 1] >= a[pr] - a[pr - 1]) { h += a[pL]; t += a[pL + 1]; pL += 2; } else { h += a[pr]; t += a[pr - 1]; pr -= 2; } } h += Max(a[pL], a[pr]); t += Min(a[pL], a[pr]); Console.WriteLine(h - t); } }