/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 320.0 KiB
#3 Wrong Answer 2ms 320.0 KiB
#4 Wrong Answer 2ms 576.0 KiB
#5 Wrong Answer 2ms 580.0 KiB
#6 Wrong Answer 5ms 604.0 KiB
#7 Wrong Answer 40ms 1.945 MiB
#8 Wrong Answer 35ms 1.5 MiB
#9 Wrong Answer 36ms 1.738 MiB
#10 Accepted 29ms 2.188 MiB
#11 Wrong Answer 31ms 2.059 MiB

Code

/**
 *  written by Binoy Barman .
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define int long long

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
        Too_Many_Jobs {
            int n, k;
            cin >> n >> k;
            if (n >= k) {
                cout << 0 << nl;
                goto hell;
            }
            int L = 1, H = k, mid, ans = 0, ans2 = 0;
            while (L <= H) {
                mid = (L + H) >> 1;
                if (mid + (mid * n) > k) {
                    H = mid - 1;
                }
                else {
                    ans2 = max(ans2, (mid + (k - (mid + (mid * n)))) * mid);
                    ans = mid;
                    L = mid + 1;
                }
            }
            int x = ans + (k - (ans + (ans * n))), y = ans;
            dbg(k, ans, x, y, x * y);
            cout << max({x * y, (x + n) * (y - 1), ans2}) << nl;
        }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 16:50:42
Judged At
2024-10-03 13:06:00
Judged By
Score
11
Total Time
40ms
Peak Memory
2.188 MiB