結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー fastmathfastmath
提出日時 2021-01-22 22:29:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,514 bytes
コンパイル時間 2,650 ms
コンパイル使用メモリ 214,724 KB
実行使用メモリ 43,572 KB
最終ジャッジ日時 2023-08-27 20:18:14
合計ジャッジ時間 27,177 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,440 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 153 ms
5,716 KB
testcase_19 AC 49 ms
4,376 KB
testcase_20 AC 158 ms
5,644 KB
testcase_21 AC 38 ms
4,732 KB
testcase_22 AC 61 ms
4,568 KB
testcase_23 AC 107 ms
5,316 KB
testcase_24 AC 84 ms
5,400 KB
testcase_25 AC 95 ms
5,220 KB
testcase_26 AC 129 ms
5,716 KB
testcase_27 AC 76 ms
4,676 KB
testcase_28 AC 1,144 ms
23,680 KB
testcase_29 AC 969 ms
16,272 KB
testcase_30 AC 938 ms
15,472 KB
testcase_31 AC 1,407 ms
25,732 KB
testcase_32 AC 878 ms
28,648 KB
testcase_33 AC 897 ms
15,428 KB
testcase_34 AC 1,404 ms
26,556 KB
testcase_35 AC 1,816 ms
26,608 KB
testcase_36 TLE -
testcase_37 AC 418 ms
13,136 KB
testcase_38 AC 1,365 ms
19,588 KB
testcase_39 AC 724 ms
15,300 KB
testcase_40 AC 923 ms
16,212 KB
testcase_41 AC 1,267 ms
22,588 KB
testcase_42 TLE -
testcase_43 AC 1,266 ms
23,792 KB
testcase_44 AC 1,994 ms
26,412 KB
testcase_45 AC 1,640 ms
20,432 KB
testcase_46 AC 1,431 ms
28,924 KB
testcase_47 AC 637 ms
15,152 KB
testcase_48 TLE -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define trav(a, x) for (auto& a : x)
using vi = vector<int>;
template <typename T>
std::ostream& operator <<(std::ostream& output, const pair <T, T> & data)
{
    output << "(" << data.x << "," << data.y << ")";
    return output;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const std::vector<T>& data)
{
    for (const T& x : data)
        output << x << " ";
    return output;
}
ll div_up(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll div_down(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down 
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>; 
tcT> void re(V<T>& x) { 
    trav(a, x)
        cin >> a;
}
tcT> bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0; 
} // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; 
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    vi sz(4);
    FOR (i, 4)
        cin >> sz[i];
    int k;
    cin >> k;
    V <vi> a(4);
    FOR (i, 4) {
        a[i].resize(sz[i]);
        re(a[i]);
    }   

    V <vi> l, r;
    trav (i, a[0])
        trav (j, a[1])
            l.app({i * j, i, j});
    sort(all(l));
    trav (i, a[2])
        trav (j, a[3])
            r.app({i * j, i, j});
    sort(all(r));
        
    const int INF = 2e18;

    auto get_left = [&] (V <vi> &a, int x) {
        vi key = {x, INF, INF};
        return upper_bound(all(a), key) - a.begin();
    };  
    auto get_right = [&] (V <vi> &a, int x) {
        return (int)a.size() - get_left(a, x - 1);
    };  

    auto cnt = [&] (int x) {
        //prod <= x
        int ans = 0;
        trav (v, l) {
            int a = v[0];
            if (a == 0) {
                if (0 <= x)
                    ans += r.size();
            }   
            else if (a < 0) {
                //a * b <= x
                //b >= x/a
                ans += get_right(r, div_up(x, a));
            }   
            else {
                //b <= x/a
                ans += get_left(r, div_down(x, a));
            }   
        }   
        return ans;
    };  

    int ans;
    {
    int l = -INF, r = INF; // l < ans
    while (l < r - 1) {
        int m = (l + r) >> 1;
        if (cnt(m) < k)
            l = m;
        else
            r = m;
    }   
    ans = r;
    cout << r << endl;
    }

    trav (v, l) {
        int a = v[0];

        if (ans == 0 && a == 0) {
            auto vv = r[0];
            cout << v[1] << ' ' << v[2] << ' ' << vv[1] << ' ' << vv[2] << endl;
            exit(0);
        }   
        
        if (a && ans % a == 0) {
            int b = ans/a;
            vi key = {b, -INF, -INF};
            auto t = lower_bound(all(r), key);
            if (t != r.end() && (*t)[0] == b) {
                auto vv = *t;
                cout << v[1] << ' ' << v[2] << ' ' << vv[1] << ' ' << vv[2] << endl;
                exit(0);
            }   
        }   
    }       
    assert(0);
}
0