結果

問題 No.1650 Moving Coins
ユーザー bluemeganebluemegane
提出日時 2021-08-21 07:18:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 1,804 bytes
コンパイル時間 1,827 ms
コンパイル使用メモリ 111,648 KB
実行使用メモリ 61,608 KB
最終ジャッジ日時 2024-04-22 16:45:43
合計ジャッジ時間 9,675 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
19,072 KB
testcase_01 AC 27 ms
19,072 KB
testcase_02 AC 27 ms
19,072 KB
testcase_03 AC 79 ms
25,600 KB
testcase_04 AC 68 ms
24,448 KB
testcase_05 AC 74 ms
25,216 KB
testcase_06 AC 80 ms
25,600 KB
testcase_07 AC 80 ms
25,728 KB
testcase_08 AC 177 ms
45,164 KB
testcase_09 AC 175 ms
44,104 KB
testcase_10 AC 187 ms
45,732 KB
testcase_11 AC 183 ms
46,416 KB
testcase_12 AC 145 ms
39,040 KB
testcase_13 AC 148 ms
39,552 KB
testcase_14 AC 174 ms
43,844 KB
testcase_15 AC 136 ms
38,784 KB
testcase_16 AC 189 ms
47,652 KB
testcase_17 AC 189 ms
47,844 KB
testcase_18 AC 209 ms
50,700 KB
testcase_19 AC 256 ms
59,368 KB
testcase_20 AC 258 ms
61,608 KB
testcase_21 AC 259 ms
61,480 KB
testcase_22 AC 254 ms
61,412 KB
testcase_23 AC 251 ms
61,032 KB
testcase_24 AC 83 ms
24,960 KB
testcase_25 AC 80 ms
24,832 KB
testcase_26 AC 162 ms
48,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Text;
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int id { get; set; }
    public int a { get; set; }
    public int b { get; set; }
}

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);
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        getAns(n, a, b);
    }
    static void printAsb(List<P> asb)
    {
        var c = asb.Count();
        var sb = new StringBuilder();
        for (int i = c - 1; i >= 0; i--)
        {
            var jmax = asb[i].b - asb[i].a;
            for (int j = 0; j < jmax; j++)
                sb.Append(string.Format("{0} R", asb[i].id));
        }
        Console.Write(sb);
    }
    static void printAgb(List<P> agb)
    {
        var c = agb.Count();
        var sb = new StringBuilder();
        for (int i = 0; i < c; i++)
        {
            var jmax = agb[i].a - agb[i].b;
            for (int j = 0; j < jmax; j++)
                sb.Append(string.Format("{0} L", agb[i].id));
        }
        Console.Write(sb);
    }
    static void getAns(int n, int[] a, int[] b)
    {
        var asb = new List<P>();
        var agb = new List<P>();
        var s = 0L;
        for (int i = 0; i < n; i++)
        {
            s += Abs(a[i] - b[i]);
            if (a[i] < b[i]) asb.Add(new P { id = i + 1, a = a[i], b = b[i] });
            else if (a[i] > b[i]) agb.Add(new P { id = i + 1, a = a[i], b = b[i] });
        }
        Console.WriteLine(s);
        if (agb.Count() > 0) printAgb(agb);
        if (asb.Count() > 0) printAsb(asb);
    }
}
0