結果
問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
ユーザー | firiexp |
提出日時 | 2021-01-23 00:08:17 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 253 ms / 2,000 ms |
コード長 | 3,481 bytes |
コンパイル時間 | 1,191 ms |
コンパイル使用メモリ | 112,628 KB |
実行使用メモリ | 18,144 KB |
最終ジャッジ日時 | 2024-06-09 04:45:22 |
合計ジャッジ時間 | 9,836 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 3 ms
6,944 KB |
testcase_16 | AC | 3 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 12 ms
6,944 KB |
testcase_19 | AC | 6 ms
6,940 KB |
testcase_20 | AC | 13 ms
6,948 KB |
testcase_21 | AC | 6 ms
6,940 KB |
testcase_22 | AC | 9 ms
6,940 KB |
testcase_23 | AC | 12 ms
6,940 KB |
testcase_24 | AC | 12 ms
6,940 KB |
testcase_25 | AC | 11 ms
6,944 KB |
testcase_26 | AC | 13 ms
6,944 KB |
testcase_27 | AC | 9 ms
6,940 KB |
testcase_28 | AC | 90 ms
7,840 KB |
testcase_29 | AC | 80 ms
6,588 KB |
testcase_30 | AC | 67 ms
6,724 KB |
testcase_31 | AC | 82 ms
8,616 KB |
testcase_32 | AC | 91 ms
10,096 KB |
testcase_33 | AC | 63 ms
6,624 KB |
testcase_34 | AC | 94 ms
8,300 KB |
testcase_35 | AC | 119 ms
9,716 KB |
testcase_36 | AC | 174 ms
11,816 KB |
testcase_37 | AC | 38 ms
5,628 KB |
testcase_38 | AC | 87 ms
7,352 KB |
testcase_39 | AC | 52 ms
6,132 KB |
testcase_40 | AC | 66 ms
6,584 KB |
testcase_41 | AC | 104 ms
7,892 KB |
testcase_42 | AC | 156 ms
11,364 KB |
testcase_43 | AC | 104 ms
8,908 KB |
testcase_44 | AC | 116 ms
8,752 KB |
testcase_45 | AC | 98 ms
7,848 KB |
testcase_46 | AC | 84 ms
8,476 KB |
testcase_47 | AC | 62 ms
5,888 KB |
testcase_48 | AC | 161 ms
18,140 KB |
testcase_49 | AC | 126 ms
18,144 KB |
testcase_50 | AC | 175 ms
17,884 KB |
testcase_51 | AC | 141 ms
18,140 KB |
testcase_52 | AC | 128 ms
18,140 KB |
testcase_53 | AC | 233 ms
15,812 KB |
testcase_54 | AC | 222 ms
15,816 KB |
testcase_55 | AC | 253 ms
15,692 KB |
testcase_56 | AC | 225 ms
15,692 KB |
testcase_57 | AC | 131 ms
15,816 KB |
testcase_58 | AC | 72 ms
15,684 KB |
testcase_59 | AC | 69 ms
15,816 KB |
testcase_60 | AC | 66 ms
15,688 KB |
testcase_61 | AC | 67 ms
15,816 KB |
testcase_62 | AC | 67 ms
15,684 KB |
testcase_63 | AC | 26 ms
18,144 KB |
testcase_64 | AC | 28 ms
18,140 KB |
testcase_65 | AC | 24 ms
18,144 KB |
testcase_66 | AC | 25 ms
17,884 KB |
testcase_67 | AC | 26 ms
18,008 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 1 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 <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; int main() { int a, b, c, d; ll s; cin >> a >> b >> c >> d >> s; vector<int> A(a), B(b), C(c), D(d); for (auto &&i : A) scanf("%d", &i); for (auto &&i : B) scanf("%d", &i); for (auto &&i : C) scanf("%d", &i); for (auto &&i : D) scanf("%d", &i); vector<ll> vp, up, vm, um; for (int i = 0; i < a; ++i) { for (int j = 0; j < b; ++j) { if(A[i]*B[j] >= 0) vp.emplace_back(A[i] * B[j]); else vm.emplace_back(A[i] * B[j]); } } for (int i = 0; i < c; ++i) { for (int j = 0; j < d; ++j) { if(C[i]*D[j] >= 0) up.emplace_back(C[i] * D[j]); else um.emplace_back(C[i] * D[j]); } } sort(vp.begin(),vp.end()); sort(vm.begin(),vm.end()); sort(up.begin(),up.end()); sort(um.begin(),um.end()); ll ok = INF<ll>, ng = -INF<ll>; while(ok-ng > 1){ ll mid = (ok+ng)/2; if([&](ll x) -> bool{ // count v[i]*u[j] <= x ll cnt = 0; if(x >= 0){ cnt += (ll)vp.size()*um.size()+(ll)up.size()*vm.size(); int cur = 0; for (int i = (int)vp.size()-1; i >= 0; --i) { // v >= 0, u >= 0 while(cur < up.size() && up[cur]*vp[i] <= x) cur++; cnt += cur; } cur = um.size(); for (int i = 0; i < vm.size(); ++i) { while(cur > 0 && vm[i]*um[cur-1] <= x) cur--; cnt += um.size()-cur; } }else { int cur = vp.size(); for (int i = (int)um.size()-1; i >= 0; --i) { while(cur > 0 && vp[cur-1]*um[i] <= x) cur--; cnt += vp.size()-cur; } cur = up.size(); for (int i = (int)vm.size()-1; i >= 0; --i) { while(cur > 0 && up[cur-1]*vm[i] <= x) cur--; cnt += up.size()-cur; } } return cnt >= s; }(mid)) ok = mid; else ng = mid; } cout << ok << "\n"; // 復元いる? ll ab = 0, cd = 0; for (auto &&i : vp) vm.emplace_back(i); for (auto &&i : up) um.emplace_back(i); if(ok == 0){ for (auto &&i : vm) { if(i == 0) ab = 0, cd = um[0]; } for (auto &&i : um) { if(i == 0) ab = vm[0], cd = 0; } }else { for (auto &&i : vm) { if(i == 0 || ok%i) continue; auto x = lower_bound(um.begin(),um.end(), ok/i); if(x != um.end() && *x == ok/i) ab = i, cd = ok/i; } } for (int i = 0; i < a; ++i) { for (int j = 0; j < b; ++j) { if(A[i]*B[j] == ab){ cout << A[i] << " " << B[j] << " "; i = a; j = b; } } } for (int i = 0; i < c; ++i) { for (int j = 0; j < d; ++j) { if(C[i]*D[j] == cd){ cout << C[i] << " " << D[j] << "\n"; i = c; j = d; } } } return 0; }