結果

問題 No.1597 Matrix Sort
ユーザー Mr.SpockMr.Spock
提出日時 2021-07-18 15:29:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 168,388 KB
実行使用メモリ 161,012 KB
最終ジャッジ日時 2023-09-22 17:52:48
合計ジャッジ時間 8,270 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 162 ms
160,892 KB
testcase_05 AC 180 ms
160,888 KB
testcase_06 AC 183 ms
160,984 KB
testcase_07 AC 182 ms
161,012 KB
testcase_08 AC 147 ms
160,796 KB
testcase_09 AC 172 ms
160,912 KB
testcase_10 AC 105 ms
160,788 KB
testcase_11 AC 109 ms
160,896 KB
testcase_12 AC 22 ms
4,924 KB
testcase_13 AC 49 ms
20,268 KB
testcase_14 AC 165 ms
160,776 KB
testcase_15 AC 26 ms
4,912 KB
testcase_16 AC 41 ms
20,460 KB
testcase_17 AC 125 ms
160,836 KB
testcase_18 AC 164 ms
160,864 KB
testcase_19 AC 160 ms
160,824 KB
testcase_20 AC 123 ms
160,796 KB
testcase_21 AC 118 ms
160,932 KB
testcase_22 AC 116 ms
160,784 KB
testcase_23 AC 111 ms
160,884 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 84 ms
159,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void logger(std::string, Args&& ...)’ 内:
main.cpp:9:53: 警告: fold-expressions only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
    9 |         (..., (cout << delim << values, delim = ", "));
      |                                                     ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
	cout << vars << " = [";
	string delim = "";
	(..., (cout << delim << values, delim = ", "));
	cout << "]" << " ";
}
ll n, k, p;
vector<ll>x, y, dp;
bool solve(ll mid) {
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ans += dp[p + mid - x[i]] - dp[p - x[i] - 1];
		if (mid - x[i] >= 0) {
			ans += dp[mid - x[i]];
		}
	}
	return (ans >= k);
}
void solve() {
	cin >> n >> k >> p;
	x.resize(n);
	y.resize(n);
	dp.resize(2 * p + 1);
	dp.assign(2 * p + 1, 0);
	for (ll i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> y[i];
	}
	for (int i = 0; i < n; i++) {
		dp[y[i]]++;
	}
	for (ll i = 1; i <= 2 * p; i++) {
		dp[i] += dp[i - 1];
	}
	ll L = 0, R = p + 7;
	while (R - L > 1) {
		ll mid = (L + R) / 2;
		if (solve(mid))R = mid;
		else L = mid;
	}
	cout << R << endl;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	T = 1;
	//cin >> T;
	while (T--) {
		solve();
	}
}
0