結果
問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
ユーザー | tokusakurai |
提出日時 | 2021-02-10 16:37:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 727 ms / 2,000 ms |
コード長 | 3,405 bytes |
コンパイル時間 | 2,662 ms |
コンパイル使用メモリ | 220,612 KB |
実行使用メモリ | 53,888 KB |
最終ジャッジ日時 | 2024-07-08 02:57:35 |
合計ジャッジ時間 | 22,195 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 3 ms
5,376 KB |
testcase_09 | AC | 3 ms
5,376 KB |
testcase_10 | AC | 3 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 4 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 28 ms
6,016 KB |
testcase_19 | AC | 11 ms
5,376 KB |
testcase_20 | AC | 29 ms
5,820 KB |
testcase_21 | AC | 12 ms
5,376 KB |
testcase_22 | AC | 18 ms
5,376 KB |
testcase_23 | AC | 26 ms
6,016 KB |
testcase_24 | AC | 27 ms
6,016 KB |
testcase_25 | AC | 25 ms
5,632 KB |
testcase_26 | AC | 29 ms
6,016 KB |
testcase_27 | AC | 18 ms
5,376 KB |
testcase_28 | AC | 313 ms
24,232 KB |
testcase_29 | AC | 228 ms
19,696 KB |
testcase_30 | AC | 200 ms
17,360 KB |
testcase_31 | AC | 287 ms
26,000 KB |
testcase_32 | AC | 405 ms
31,940 KB |
testcase_33 | AC | 202 ms
17,400 KB |
testcase_34 | AC | 383 ms
30,596 KB |
testcase_35 | AC | 370 ms
27,480 KB |
testcase_36 | AC | 660 ms
42,612 KB |
testcase_37 | AC | 133 ms
15,484 KB |
testcase_38 | AC | 271 ms
21,612 KB |
testcase_39 | AC | 140 ms
15,028 KB |
testcase_40 | AC | 220 ms
19,484 KB |
testcase_41 | AC | 352 ms
25,860 KB |
testcase_42 | AC | 531 ms
36,384 KB |
testcase_43 | AC | 310 ms
23,844 KB |
testcase_44 | AC | 403 ms
29,068 KB |
testcase_45 | AC | 304 ms
24,028 KB |
testcase_46 | AC | 401 ms
33,232 KB |
testcase_47 | AC | 172 ms
16,788 KB |
testcase_48 | AC | 625 ms
53,888 KB |
testcase_49 | AC | 577 ms
53,888 KB |
testcase_50 | AC | 626 ms
53,856 KB |
testcase_51 | AC | 618 ms
53,880 KB |
testcase_52 | AC | 559 ms
53,756 KB |
testcase_53 | AC | 665 ms
53,532 KB |
testcase_54 | AC | 658 ms
53,624 KB |
testcase_55 | AC | 727 ms
53,628 KB |
testcase_56 | AC | 626 ms
53,620 KB |
testcase_57 | AC | 561 ms
53,752 KB |
testcase_58 | AC | 90 ms
10,108 KB |
testcase_59 | AC | 89 ms
10,368 KB |
testcase_60 | AC | 72 ms
10,364 KB |
testcase_61 | AC | 72 ms
10,236 KB |
testcase_62 | AC | 73 ms
10,236 KB |
testcase_63 | AC | 21 ms
12,160 KB |
testcase_64 | AC | 21 ms
12,156 KB |
testcase_65 | AC | 21 ms
12,032 KB |
testcase_66 | AC | 20 ms
12,156 KB |
testcase_67 | AC | 21 ms
12,028 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 2 ms
5,376 KB |
testcase_70 | AC | 2 ms
5,376 KB |
testcase_71 | AC | 2 ms
5,376 KB |
testcase_72 | AC | 2 ms
5,376 KB |
testcase_73 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define each(e, v) for(auto &e: v) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (int)x.size() using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const int MOD = 1000000007; //const int MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; struct io_setup{ io_setup(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(15); } } io_setup; int main(){ int A, B, C, D; ll K; cin >> A >> B >> C >> D >> K; vector<ll> a(A), b(B), c(C), d(D); rep(i, A) cin >> a[i]; rep(i, B) cin >> b[i]; rep(i, C) cin >> c[i]; rep(i, D) cin >> d[i]; vector<ll> P1, P2, P3, Q; map<ll, pii> mp1, mp2; rep(i, A){ rep(j, B){ ll x = a[i]*b[j]; if(x > 0) P1.eb(x); if(x == 0) P2.eb(x); if(x < 0) P3.eb(-x); mp1[a[i]*b[j]] = pii(i, j); } } sort(all(P1)), sort(all(P3)); rep(i, C){ rep(j, D){ Q.eb(c[i]*d[j]); mp2[c[i]*d[j]] = pii(i, j); } } sort(all(Q)); int N = sz(Q); ll L = -INF, R = INF; //(L,R] while(R-L > 1){ ll M = (L+R)/2; ll cnt = 0; int ptr; if(M >= 0){ ptr = N; each(e, P1){ while(ptr > 0 && e*Q[ptr-1] > M) ptr--; cnt += ptr; } cnt += 1LL*sz(P2)*N; ptr = 0; each(e, P3){ while(ptr < N && e*Q[ptr] < -M) ptr++; cnt += N-ptr; } } else{ ptr = 0; each(e, P1){ while(ptr < N && e*Q[ptr] <= M) ptr++; cnt += ptr; } ptr = N; each(e, P3){ while(ptr > 0 && e*Q[ptr-1] >= -M) ptr--; cnt += N-ptr; } } (cnt >= K? R : L) = M; } cout << R << '\n'; if(R == 0){ each(e, mp1){ if(e.first != 0) continue; auto [i, j] = e.second; cout << a[i] << ' ' << b[j] << ' ' << c[0] << ' ' << d[0] << '\n'; return 0; } each(e, mp2){ if(e.first != 0) continue; auto [i, j] = e.second; cout << a[0] << ' ' << b[0] << ' ' << c[i] << ' ' << d[j] << '\n'; return 0; } } each(e, mp1){ if(e.first == 0) continue; int flag = 0; if(R < 0) flag ^= 1; if(e.first < 0) flag ^= 1; if(abs(R)%abs(e.first) != 0) continue; ll x = abs(R)/abs(e.first); if(flag) x *= -1; if(mp2.count(x)){ auto [i, j] = e.second; auto [k, l] = mp2[x]; cout << a[i] << ' ' << b[j] << ' ' << c[k] << ' ' << d[l] << '\n'; return 0; } } }