結果

問題 No.966 引き算をして門松列(その1)
コンテスト
ユーザー kakel-san
提出日時 2025-12-13 23:35:31
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,664 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,033 ms
コンパイル使用メモリ 169,076 KB
実行使用メモリ 192,924 KB
最終ジャッジ日時 2025-12-13 23:35:40
合計ジャッジ時間 8,168 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ミリ秒)。
  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 int[t];
        for (var i = 0; i < t; ++i)
        {
            var c = NList;
            ans[i] = Kado(c[0], c[1], c[2]);
        }
        WriteLine(string.Join("\n", ans));
    }
    static int Kado(int a, int b, int c)
    {
        if (a > b && b < c)
        {
            if (a != c) return 0;
            if (a == 2) return -1;
            if (a - b == 1) return 2;
            return 1;
        }
        if (a < b && b > c)
        {
            if (a != c) return 0;
            if (a == 1) return -1;
            return 1;
        }
        if (a > c) (a, c) = (c, a);
        // ここから a <= b, b <= c
        if (a == c)
        {
            if (a < 3) return -1;
            return 3;
        }
        if (a == b)
        {
            if (a < 2) return -1;
            return 1;
        }
        if (b == c)
        {
            if (b < 2) return -1;
            return 1;
        }
        // ここから a < b < c
        if (b == 2) return -1;
        if (a == 1)
        {
            return c - b + 1;
        }
        return Math.Min(c - b, b - a) + 1;
    }
}
0