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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.