結果

問題 No.1650 Moving Coins
ユーザー bluemeganebluemegane
提出日時 2021-08-21 07:13:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 1,567 bytes
コンパイル時間 3,322 ms
コンパイル使用メモリ 105,984 KB
実行使用メモリ 56,756 KB
最終ジャッジ日時 2024-04-22 16:39:31
合計ジャッジ時間 20,174 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
18,816 KB
testcase_01 AC 26 ms
18,816 KB
testcase_02 AC 28 ms
18,944 KB
testcase_03 AC 502 ms
22,784 KB
testcase_04 AC 403 ms
23,040 KB
testcase_05 AC 471 ms
22,784 KB
testcase_06 AC 535 ms
22,912 KB
testcase_07 AC 523 ms
22,784 KB
testcase_08 AC 621 ms
40,704 KB
testcase_09 AC 640 ms
40,192 KB
testcase_10 AC 654 ms
41,208 KB
testcase_11 AC 634 ms
41,216 KB
testcase_12 AC 622 ms
36,352 KB
testcase_13 AC 611 ms
36,864 KB
testcase_14 AC 645 ms
40,192 KB
testcase_15 AC 595 ms
33,024 KB
testcase_16 AC 648 ms
43,008 KB
testcase_17 AC 634 ms
43,392 KB
testcase_18 AC 657 ms
47,880 KB
testcase_19 AC 738 ms
55,320 KB
testcase_20 AC 720 ms
56,700 KB
testcase_21 AC 707 ms
56,312 KB
testcase_22 AC 711 ms
56,756 KB
testcase_23 AC 730 ms
56,636 KB
testcase_24 AC 529 ms
22,656 KB
testcase_25 AC 535 ms
22,656 KB
testcase_26 AC 163 ms
48,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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();
        for (int i = c - 1; i >= 0; i--)
        {
            var jmax = asb[i].b - asb[i].a;
            for (int j = 0; j < jmax; j++) Console.WriteLine("{0} R", asb[i].id);
        }
    }
    static void printAgb(List<P> agb)
    {
        var c = agb.Count();
        for (int i = 0; i < c; i++)
        {
            var jmax = agb[i].a - agb[i].b;
            for (int j = 0; j < jmax; j++) Console.WriteLine("{0} L", agb[i].id);
        }
    }
    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);
        printAgb(agb);
        printAsb(asb);
    }
}
0