結果
| 問題 | No.967 引き算をして門松列(その2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-15 23:31:22 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| コード長 | 2,522 bytes |
| 記録 | |
| コンパイル時間 | 7,810 ms |
| コンパイル使用メモリ | 170,756 KB |
| 実行使用メモリ | 195,984 KB |
| 最終ジャッジ日時 | 2025-12-15 23:31:46 |
| 合計ジャッジ時間 | 9,487 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (108 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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 == a)
{
if (lb > 1) ans = Math.Min(ans, y * (b - lb + 1) + Math.Min(x, z));
}
else ans = Math.Min(ans, y * (b - lb) + Math.Min(x, z));
}
else
{
if (lb > 0) ans = Math.Min(ans, y * (b - lb));
}
}
return ans;
}
static long INF = long.MaxValue / 2;
}