結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2021-08-21 07:18:22 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 250 ms / 2,000 ms |
| コード長 | 1,804 bytes |
| コンパイル時間 | 3,304 ms |
| コンパイル使用メモリ | 109,572 KB |
| 実行使用メモリ | 69,320 KB |
| 最終ジャッジ日時 | 2024-10-14 15:55:57 |
| 合計ジャッジ時間 | 10,732 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}
bluemegane