結果

問題 No.929 よくあるボールを移動するやつ
ユーザー bluemeganebluemegane
提出日時 2021-04-24 17:13:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 63,928 KB
実行使用メモリ 30,548 KB
最終ジャッジ日時 2023-09-17 13:39:15
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
19,360 KB
testcase_01 AC 60 ms
21,468 KB
testcase_02 AC 59 ms
21,324 KB
testcase_03 AC 61 ms
23,396 KB
testcase_04 AC 59 ms
21,332 KB
testcase_05 AC 61 ms
21,328 KB
testcase_06 AC 67 ms
21,584 KB
testcase_07 AC 78 ms
20,916 KB
testcase_08 AC 94 ms
25,212 KB
testcase_09 AC 94 ms
27,336 KB
testcase_10 AC 92 ms
30,376 KB
testcase_11 AC 92 ms
30,344 KB
testcase_12 AC 93 ms
28,456 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0