結果

問題 No.1597 Matrix Sort
ユーザー さかぽんさかぽん
提出日時 2021-07-09 23:06:15
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,027 bytes
コンパイル時間 4,514 ms
コンパイル使用メモリ 108,288 KB
実行使用メモリ 48,224 KB
最終ジャッジ日時 2023-09-14 10:40:53
合計ジャッジ時間 33,909 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
19,612 KB
testcase_01 AC 71 ms
23,936 KB
testcase_02 AC 69 ms
21,712 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,368 ms
44,188 KB
testcase_09 AC 1,408 ms
44,056 KB
testcase_10 AC 835 ms
41,956 KB
testcase_11 AC 864 ms
44,140 KB
testcase_12 AC 1,061 ms
40,160 KB
testcase_13 AC 1,439 ms
45,260 KB
testcase_14 TLE -
testcase_15 AC 628 ms
42,132 KB
testcase_16 AC 928 ms
44,924 KB
testcase_17 AC 1,045 ms
45,984 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 991 ms
43,388 KB
testcase_23 AC 922 ms
44,168 KB
testcase_24 AC 207 ms
36,176 KB
testcase_25 AC 203 ms
36,328 KB
testcase_26 AC 68 ms
21,896 KB
testcase_27 AC 69 ms
23,760 KB
testcase_28 AC 70 ms
23,868 KB
testcase_29 AC 69 ms
21,752 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Linq;

class G
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static (long, long, long) Read3L() { var a = ReadL(); return (a[0], a[1], a[2]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var (n, k, p) = ((int, long, int))Read3L();
		var a = Read();
		var b = Read();

		Array.Sort(b);
		b = b.Concat(b.Select(v => v + p)).ToArray();

		return First(0, p, x =>
		{
			// x までの個数
			var c = 0L;

			foreach (var v in a)
			{
				var l = First(0, b.Length, i => v + b[i] >= p);
				var r = First(0, b.Length, i => v + b[i] > p + x);
				c += r - l;
			}
			return c >= k;
		});
	}

	static int First(int l, int r, Func<int, bool> f)
	{
		int m;
		while (l < r) if (f(m = l + (r - l - 1) / 2)) r = m; else l = m + 1;
		return r;
	}
}
0