/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 540.0 KiB
#2 Wrong Answer 41ms 1.27 MiB

Code

#include <bits/stdc++.h>
#define nl '\n'
#define ll long long int
#define all(c) c.begin(),c.end()
#define print(c) for(auto e : c) cout << e << " "; cout << nl
using namespace std;
void solve()
{
    int l, r, x; cin >> l >> r >> x;

    ll hi = r, lo = l;

    while (lo <= hi)
    {
        ll mid = lo + (hi-lo)/2;
        ll data = mid + x;
        if(data >= l && data <= r)
        {
            cout << mid << " " << data << nl; return;
        }
        else if(data > hi) hi = mid - 1;
        else lo = mid + 1;
    }
    
    cout << -1 << " " << -1 << nl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int t; cin >> t;
    for(int tt = 1; tt <= t; tt++)
    {
        // cout << "TEST CASE-" << tt << nl;
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1186 Equal to X
Contest
Brain Booster #9
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 15:47:11
Judged At
2025-04-06 15:47:11
Judged By
Score
0
Total Time
41ms
Peak Memory
1.27 MiB