結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-02-29 08:21:43 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,659 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 105,856 KB |
実行使用メモリ | 43,136 KB |
最終ジャッジ日時 | 2024-10-13 19:49:48 |
合計ジャッジ時間 | 3,353 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var sol = new Solve(); sol.Exec(); } } class Solve { public void Exec() { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split().Select(int.Parse).ToArray(); var acumFoward = new List<int>(); var acumBack = new List<int>(); for (var i = 1; i < 2 * N; i+=2) { acumFoward.Add(A[i - 1] - A[i]); acumBack.Add(A[A.Length - 1 - i + 1] - A[A.Length - 1 - i]); } var left = 0; var right = 0; var ans = 0L; var correction = 0; for (var i = 0; i < N; i++) { if (acumFoward[left] > acumBack[right]) { ans += acumFoward[left]; left++; if (correction != 0) { right -= correction; correction = 0; } } else if (acumFoward[left] < acumBack[right]) { ans += acumBack[right]; right++; if (correction != 0) { left -= correction; correction = 0; } } else { if (i == N - 1) left -= correction; ans += acumFoward[left]; correction++; left++; right++; } } Console.WriteLine(ans); } } public class Util { }