結果

問題 No.967 引き算をして門松列(その2)
コンテスト
ユーザー kakel-san
提出日時 2025-12-15 23:25:12
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 2,372 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,701 ms
コンパイル使用メモリ 170,340 KB
実行使用メモリ 195,648 KB
最終ジャッジ日時 2025-12-15 23:25:29
合計ジャッジ時間 11,173 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (124 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #
raw source code

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.Intrinsics.Arm;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new long[t];
        for (var i = 0; i < t; ++i)
        {
            var c = NList;
            ans[i] = Kado(c[0], c[1], c[2], c[3], c[4], c[5]);
        }
        WriteLine(string.Join("\n", ans));
    }
    static long Kado(int a, int b, int c, long x, long y, long z)
    {
        var ans = Math.Min(LHL(a, b, c, x, y, z), HLH(a, b, c, x, y, z));
        return ans == INF ? -1 : ans;
    }
    static long LHL(int a, int b, int c, long x, long y, long z)
    {
        if (a == c && a == 1) return INF;
        if (b < 3) return INF;
        var ans = INF;
        {
            var la = Math.Min(a, b - 1);
            var lc = Math.Min(c, b - 2);
            if (la == lc)
            {
                if (la > 1) ans = Math.Min(ans, x * (a - la) + z * (c - lc) + Math.Min(x, z));
            }
            else
            {
                ans = Math.Min(ans, x * (a - la) + z * (c - lc));
            }
        }
        {
            var la = Math.Min(a, b - 2);
            var lc = Math.Min(c, b - 1);
            if (la == lc)
            {
                if (la > 1) ans = Math.Min(ans, x * (a - la) + z * (c - lc) + Math.Min(x, z));
            }
            else
            {
                ans = Math.Min(ans, x * (a - la) + z * (c - lc));
            }
        }
        return ans;
    }
    static long HLH(int a, int b, int c, long x, long y, long z)
    {
        var ans = INF;
        {
            var lb = Math.Min(b, Math.Min(a, c) - 1);
            if (a == c)
            {
                if (lb > 1) ans = Math.Min(ans, y * (b - lb + 1) + Math.Min(x, z));
            }
            else
            {
                if (lb > 0) ans = Math.Min(ans, y * (b - lb));
            }
        }
        return ans;
    }
    static long INF = long.MaxValue / 2;
}
0