/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 37ms 1.27 MiB
#3 Accepted 47ms 1.77 MiB
#4 Accepted 43ms 2.52 MiB

Code

#include <bits/stdc++.h>

#define JAISHRIRAM     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TxtIO          freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define f(i,a,b)       for(int i=a;i<b;i++)
#define input          for(auto &it:arr){cin>>it;}
#define pb             push_back
#define ll             long long

using namespace std;

void solve(){
    ll l,r,x;
    cin>>l>>r>>x;
    // l<=p<=r
    // l<=q<=r
    //p-q = r
    
    if(x<0){
        //it means p less than q:
        ll p = l, q =l-x;
        
        if(q<=r){
            cout<<p<<" "<<q<<"\n";
        }else{
            cout<<-1<<" "<<-1<<"\n";
        }
    }else{
        //x>=0 => p is greater than q;
        ll p = r, q = r-x;
        if(q>=l){
            cout<<p<<" "<<q<<"\n";
        }else{
            cout<<-1<<" "<<-1<<"\n";
        }
    }
    
    

    
    
}


int main() {
   JAISHRIRAM
   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-06-12 11:43:09
Judged At
2025-06-12 11:43:09
Judged By
Score
100
Total Time
47ms
Peak Memory
2.52 MiB