Codeforces Round 858 (Div. 2) 1806A - Walking Master Solution
Problem Link : https://codeforces.com/contest/1806/problem/A
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- /// Abul Hasnat Tonmoy
- /// Department of CSE,23rd batch
- /// Islamic University,Bangladesh
- ///**********ALLAH IS ALMIGHTY************///
- #include <bits/stdc++.h>
- using namespace std ;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int test ;
- cin >> test ;
- while ( test-- ){
- int a , b , c , d ;
- cin >> a >> b >> c >> d ;
- int v ;
- v = a + d - b ;
- if ( v < c ) {
- cout <<"-1"<<endl;
- continue ;
- }
- if ( d < b ) {
- cout <<"-1"<<endl;
- continue ;
- }
- cout << (d-b) + abs(v -c ) <<endl;
- }
- return 0 ;
- }
No comments