結果
| 問題 |
No.1597 Matrix Sort
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-18 15:29:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,105 bytes |
| コンパイル時間 | 1,700 ms |
| コンパイル使用メモリ | 170,392 KB |
| 実行使用メモリ | 161,084 KB |
| 最終ジャッジ日時 | 2024-07-08 09:13:01 |
| 合計ジャッジ時間 | 5,646 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 |
コンパイルメッセージ
main.cpp: In function 'void logger(std::string, Args&& ...)':
main.cpp:9:53: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
9 | (..., (cout << delim << values, delim = ", "));
| ^
ソースコード
#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();
}
}