Codeforces Round 858 (Div. 2) 1806A - Walking Master Solution


 

Problem Link : https://codeforces.com/contest/1806/problem/A

Solution in C++:

  1. /// La ilaha illellahu muhammadur rasulullah
  2. ///******Bismillahir-Rahmanir-Rahim******///
  3. /// Abul Hasnat Tonmoy
  4. /// Department of CSE,23rd batch
  5. /// Islamic University,Bangladesh
  6. ///**********ALLAH IS ALMIGHTY************///
  7. #include <bits/stdc++.h>
  8. using namespace std ;
  9. int32_t main() {
  10. ios_base::sync_with_stdio(0);
  11. cin.tie(0);
  12. int test ;
  13. cin >> test ;
  14. while ( test-- ){
  15. int a , b , c , d ;
  16. cin >> a >> b >> c >> d ;
  17. int v ;
  18. v = a + d - b ;
  19. if ( v < c ) {
  20. cout <<"-1"<<endl;
  21. continue ;
  22. }
  23. if ( d < b ) {
  24. cout <<"-1"<<endl;
  25. continue ;
  26. }
  27. cout << (d-b) + abs(v -c ) <<endl;
  28. }
  29. return 0 ;
  30. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.