結果

問題 No.1597 Matrix Sort
ユーザー olpheolphe
提出日時 2021-07-09 22:12:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 1,500 ms
コード長 1,190 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 111,144 KB
実行使用メモリ 160,112 KB
最終ジャッジ日時 2023-09-14 09:23:16
合計ジャッジ時間 4,496 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 151 ms
160,036 KB
testcase_04 AC 146 ms
160,112 KB
testcase_05 AC 145 ms
160,036 KB
testcase_06 AC 142 ms
160,036 KB
testcase_07 AC 149 ms
159,876 KB
testcase_08 AC 132 ms
159,976 KB
testcase_09 AC 134 ms
159,972 KB
testcase_10 AC 86 ms
159,920 KB
testcase_11 AC 88 ms
160,024 KB
testcase_12 AC 18 ms
4,376 KB
testcase_13 AC 50 ms
19,296 KB
testcase_14 AC 147 ms
160,080 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 30 ms
19,608 KB
testcase_17 AC 103 ms
160,100 KB
testcase_18 AC 142 ms
160,028 KB
testcase_19 AC 130 ms
160,096 KB
testcase_20 AC 97 ms
160,024 KB
testcase_21 AC 89 ms
159,924 KB
testcase_22 AC 91 ms
159,868 KB
testcase_23 AC 88 ms
159,992 KB
testcase_24 AC 13 ms
4,376 KB
testcase_25 AC 13 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 68 ms
159,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> K >> M;
	vector<long long>a(N);
	vector<long long>b(2 * M);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> L;
		b[L]++;
		b[L + M]++;
	}
	for (int i = 1; i < 2 * M; i++) {
		b[i] += b[i - 1];
	}
	L = -1, R = M - 1;
	while (R - L > 1) {
		int mid = (L + R) / 2;
		long long num = 0;
		for (int i = 0; i < N; i++) {
			num += b[M + mid - a[i]] - b[M - a[i] - 1];
		}
		if (num < K)L = mid;
		else R = mid;
	}
	cout << R << endl;
}
0