結果
問題 | No.1597 Matrix Sort |
ユーザー | Joe75792433 |
提出日時 | 2021-07-09 22:04:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 321 ms / 1,500 ms |
コード長 | 2,162 bytes |
コンパイル時間 | 4,455 ms |
コンパイル使用メモリ | 263,660 KB |
実行使用メモリ | 4,500 KB |
最終ジャッジ日時 | 2023-09-14 09:09:28 |
合計ジャッジ時間 | 11,147 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 305 ms
4,376 KB |
testcase_04 | AC | 321 ms
4,380 KB |
testcase_05 | AC | 314 ms
4,500 KB |
testcase_06 | AC | 298 ms
4,376 KB |
testcase_07 | AC | 310 ms
4,380 KB |
testcase_08 | AC | 259 ms
4,380 KB |
testcase_09 | AC | 263 ms
4,380 KB |
testcase_10 | AC | 151 ms
4,380 KB |
testcase_11 | AC | 157 ms
4,376 KB |
testcase_12 | AC | 129 ms
4,376 KB |
testcase_13 | AC | 239 ms
4,380 KB |
testcase_14 | AC | 269 ms
4,380 KB |
testcase_15 | AC | 98 ms
4,380 KB |
testcase_16 | AC | 155 ms
4,380 KB |
testcase_17 | AC | 176 ms
4,376 KB |
testcase_18 | AC | 295 ms
4,376 KB |
testcase_19 | AC | 209 ms
4,380 KB |
testcase_20 | AC | 166 ms
4,376 KB |
testcase_21 | AC | 163 ms
4,376 KB |
testcase_22 | AC | 164 ms
4,380 KB |
testcase_23 | AC | 155 ms
4,380 KB |
testcase_24 | AC | 24 ms
4,380 KB |
testcase_25 | AC | 21 ms
4,380 KB |
testcase_26 | AC | 2 ms
4,376 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 2 ms
4,380 KB |
testcase_29 | AC | 1 ms
4,380 KB |
ソースコード
#ifdef _DEBUG #include <atcoder/all.h> #define debug(x) std::cout << #x << ": " << x << std::endl #else #include <bits/stdc++.h> #include <atcoder/all> //#pragma GCC target("arch=skylake-avx512") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define debug(x) #endif using namespace std; using namespace atcoder; using ll = long long; #define rep(...) _overloadrep(__VA_ARGS__, _rep4, _rep3, _rep2)(__VA_ARGS__) #define _overloadrep(_1, _2, _3, _4, _repn, ...) _repn #define _rep2(i, n) _rep4(i, 0, n, 1) #define _rep3(i, a, b) _rep4(i, a, b, 1) #define _rep4(i, a, b, s) for (auto i = (a); i < (b); i += (s)) #define repr(i, a, b) for (auto i = (b)-1; i >= (a); --i) #define all(x) (x).begin(), (x).end() #define siz(x) int((x).size()) template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) { if (a < b) { a = b; return true; } return false; } template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) { if (a > b) { a = b; return true; } return false; } constexpr char enl = '\n'; constexpr int dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; constexpr long double eps = 1e-10; constexpr int INF = 1010000000; // 1e9 constexpr ll llINF = 3010000000000000000LL; // 3e18 constexpr ll MOD = 1000000007LL; //constexpr ll MOD = 998244353LL; using mint = static_modint<MOD>; void Main([[maybe_unused]] int testcase_i) { ll n, k, p; cin >> n >> k >> p; vector<int> a(n), b(n); for (auto &t : a) cin >> t; for (auto &t : b) cin >> t; sort(all(a)); sort(all(b)); auto can = [&](int m) -> bool { ll cnt = 0; rep(i, n) { cnt += upper_bound(all(b), m-a[i]) - b.begin(); cnt += upper_bound(all(b), m+p-a[i]) - lower_bound(all(b), p-a[i]); } return cnt >= k; }; int ok = p-1, ng = -1; while (abs(ok-ng) > 1) { int mid = (ok+ng) / 2; (can(mid) ? ok : ng) = mid; } cout << ok << enl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int t = 1; //cin >> t; rep(i, t) Main(i); }