結果

問題 No.2057 Ising Model
ユーザー kakel-sankakel-san
提出日時 2022-08-26 21:46:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 104,064 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2024-10-13 22:18:25
合計ジャッジ時間 4,222 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, a, b) = (c[0], c[1], c[2]);
        var res = a * (n - 1) - b * n;
        if (n % 2 == 0)
        {
            var dbl = n / 2 - 1;
            if (a * 2 > b) res += (b - a * 2) * dbl * 2;
            if (a > b) res += (b - a) * 2;
        }
        else
        {
            var dbl = n / 2;
            if (a * 2 > b) res += (b - a * 2) * dbl * 2;
        }
        WriteLine(res);
    }
}
0