Codeforces 1257A. Two Rival Students Solution

Solve in C++:
  1. ///**********ALLAH IS ALMIGHTY************//
  2. ///AH Tonmoy
  3. ///Department of CSE
  4. ///Islamic University,Bangladesh
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7. int main()
  8. {
  9. int t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. int n,x,a,b;
  14. cin>>n>>x>>a>>b;
  15. int r1,r2;
  16. r1=x+abs(a-b);
  17. r2=min(r1,n-1);
  18. cout<<r2<<endl;
  19. }
  20. }

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 &g...

Powered by Blogger.