結果

問題 No.1345 Beautiful BINGO
ユーザー さかぽんさかぽん
提出日時 2021-01-24 19:22:29
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,248 bytes
コンパイル時間 6,230 ms
コンパイル使用メモリ 109,292 KB
実行使用メモリ 30,028 KB
最終ジャッジ日時 2023-09-01 23:06:51
合計ジャッジ時間 56,214 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,808 KB
testcase_01 AC 67 ms
21,912 KB
testcase_02 AC 68 ms
23,860 KB
testcase_03 AC 66 ms
23,768 KB
testcase_04 AC 69 ms
23,808 KB
testcase_05 AC 67 ms
23,724 KB
testcase_06 AC 65 ms
23,776 KB
testcase_07 AC 70 ms
25,756 KB
testcase_08 AC 67 ms
21,676 KB
testcase_09 AC 68 ms
23,844 KB
testcase_10 AC 67 ms
23,776 KB
testcase_11 AC 67 ms
23,708 KB
testcase_12 AC 66 ms
23,896 KB
testcase_13 AC 70 ms
25,812 KB
testcase_14 AC 66 ms
23,800 KB
testcase_15 AC 67 ms
21,668 KB
testcase_16 AC 66 ms
21,720 KB
testcase_17 AC 66 ms
23,784 KB
testcase_18 AC 68 ms
23,704 KB
testcase_19 AC 68 ms
21,736 KB
testcase_20 AC 67 ms
21,812 KB
testcase_21 AC 66 ms
23,840 KB
testcase_22 AC 177 ms
27,984 KB
testcase_23 TLE -
testcase_24 AC 1,301 ms
23,892 KB
testcase_25 AC 115 ms
27,972 KB
testcase_26 AC 611 ms
23,900 KB
testcase_27 TLE -
testcase_28 AC 114 ms
25,916 KB
testcase_29 AC 606 ms
25,916 KB
testcase_30 AC 305 ms
29,804 KB
testcase_31 AC 174 ms
29,932 KB
testcase_32 AC 75 ms
23,884 KB
testcase_33 TLE -
testcase_34 AC 88 ms
25,900 KB
testcase_35 AC 91 ms
27,888 KB
testcase_36 TLE -
testcase_37 AC 83 ms
25,952 KB
testcase_38 AC 611 ms
25,840 KB
testcase_39 TLE -
testcase_40 AC 1,287 ms
25,880 KB
testcase_41 AC 1,173 ms
25,764 KB
testcase_42 AC 68 ms
21,860 KB
testcase_43 AC 67 ms
21,724 KB
testcase_44 AC 67 ms
23,868 KB
testcase_45 AC 67 ms
21,852 KB
testcase_46 AC 67 ms
19,808 KB
testcase_47 AC 66 ms
23,752 KB
testcase_48 AC 66 ms
21,648 KB
testcase_49 AC 66 ms
21,776 KB
testcase_50 AC 67 ms
23,772 KB
testcase_51 AC 68 ms
19,756 KB
testcase_52 TLE -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 TLE -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 TLE -
testcase_61 TLE -
testcase_62 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Numerics;

class D
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static void Main()
	{
		var (n, m) = Read2();
		var a = Array.ConvertAll(new bool[n], _ => Read());
		var rowSums = a.Select(v => v.Sum()).ToArray();

		var min = 1 << 30;
		var b = new bool[n, n];
		var rn = Enumerable.Range(0, n).ToArray();

		for (int x = 0; x < 1 << n + 2; x++)
		{
			Array.Clear(b, 0, n * n);
			var count = 0;

			for (int j = 0; j < n; j++)
			{
				if ((x & (1 << j)) == 0) continue;
				for (int i = 0; i < n; i++) b[i, j] = true;
				count++;
			}
			if ((x & (1 << n)) != 0)
			{
				for (int i = 0; i < n; i++) b[i, i] = true;
				count++;
			}
			if ((x & (1 << n + 1)) != 0)
			{
				for (int i = 0; i < n; i++) b[i, n - 1 - i] = true;
				count++;
			}

			var rows = Array.ConvertAll(rn, i => rn.Sum(j => b[i, j] ? a[i][j] : 0));
			var sum = rows.Sum();

			if (count >= m) { min = Math.Min(min, sum); continue; }

			var diffs = Array.ConvertAll(rn, i => rowSums[i] - rows[i]);
			Array.Sort(diffs);
			min = Math.Min(min, sum + diffs.Take(m - count).Sum());
		}

		Console.WriteLine(min);
	}
}
0