結果

問題 No.149 碁石の移動
ユーザー kmtrc130
提出日時 2017-05-17 09:23:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 946 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 109,184 KB
実行使用メモリ 26,004 KB
最終ジャッジ日時 2024-12-24 03:24:01
合計ジャッジ時間 1,749 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] Awb = Console.ReadLine().Split(' ');
        string[] Bwb = Console.ReadLine().Split(' ');
        string[] CD = Console.ReadLine().Split(' ');

        int Aw = int.Parse(Awb[0]);
        int Ab = int.Parse(Awb[1]);
        int Bw = int.Parse(Bwb[0]);
        int Bb = int.Parse(Bwb[1]);
        int C = int.Parse(CD[0]);
        int D = int.Parse(CD[1]);

        // A→B
        Ab -= C;
        Bb += C;
        if (Ab < 0)
        {
            Aw -= Math.Abs(Ab);
            Bw += Math.Abs(Ab);
            Bb -= Math.Abs(Ab);
            Ab += Math.Abs(Ab);
        }

        // B→A
        Bw -= D;
        Aw += D;
        if (Bw < 0)
        {
            Bb -= Math.Abs(Bw);
            Ab += Math.Abs(Bw);
            Aw -= Math.Abs(Bw);
            Bw += Math.Abs(Bw);
        }

        Console.WriteLine(Aw);
    }
}
0