結果
問題 |
No.929 よくあるボールを移動するやつ
|
ユーザー |
![]() |
提出日時 | 2021-04-24 17:13:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 813 bytes |
コンパイル時間 | 744 ms |
コンパイル使用メモリ | 112,056 KB |
実行使用メモリ | 33,664 KB |
最終ジャッジ日時 | 2024-07-04 09:07:37 |
合計ジャッジ時間 | 2,297 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq; using System.Collections.Generic; 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 b0 = new List<int>(); var b1 = new List<int>(); for (int i = 0; i < n; i++) { if (a[i] == 0) b0.Add(i); else { for (int j = 0; j < a[i] - 1; j++) b1.Add(i); } } var bL = b0.Count(); var count = 0; for (int i = 0; i < bL; i++) count += Abs(b0[i] - b1[i]); Console.WriteLine(count); } }