結果

問題 No.1597 Matrix Sort
ユーザー Example0911Example0911
提出日時 2021-07-09 23:17:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 200,216 KB
実行使用メモリ 160,356 KB
最終ジャッジ日時 2023-09-14 10:48:02
合計ジャッジ時間 5,820 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 136 ms
160,104 KB
testcase_04 AC 140 ms
160,224 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 82 ms
160,156 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 46 ms
19,608 KB
testcase_14 AC 139 ms
160,220 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 97 ms
160,036 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 82 ms
160,172 KB
testcase_24 AC 15 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 58 ms
159,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define int long long

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 1000000007;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, K, P; cin >> N >> K >> P;
	vector<int>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	vector<int>tmp(P);
	for (int i = 0; i < N; i++) {
		int B; cin >> B;
		tmp[B]++;
	}
	vector<int>sum(P + 1);
	for (int i = 0; i < P; i++)sum[i + 1] = sum[i] + tmp[i];
	int l = -1, r = P;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] <= mid) {
				cnt += sum[mid - A[i] + 1];
			}
			cnt += sum[min(P, P + mid - A[i])] - sum[P - A[i] - 1];
			
		}
		if (cnt >= K)r = mid;
		else l = mid;
	}
	cout << r << endl;
	return 0;


}

0