/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 35ms 1.254 MiB
#3 Accepted 40ms 1.715 MiB
#4 Accepted 41ms 2.246 MiB

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define debug(x) cout << "Debug : " << x << endl;
const double PI = 2 * acos(0.0);
const int MOD = 1000000007;

void solve(){
    ll a, b, c;
    cin >> a >> b >> c;

    ll low = a, high = b;

    while (low <= high){
        ll mid = low + (high - low) / 2;
        ll val = (mid - c);

        if (val >= a && val <= b){
            cout << mid << ' ' << val << endl;
            return;
        }
        else if (val < a){
            low = mid + 1;
        }
        else{
            high = mid - 1;
        }
    }

    cout << -1 << ' ' << -1 << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1186 Equal to X
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-12 10:59:41
Judged At
2025-04-12 10:59:41
Judged By
Score
100
Total Time
41ms
Peak Memory
2.246 MiB