Codeforces 1257A Two Rival Students

思路:

贪心即可

代码:

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rpn(i,n) for(int i=1;i<=n;i++)
int main(){
	IOS;
	int t;
	cin>>t;
	rp(i,t){
		int n,x,a,b;
		cin>>n>>x>>a>>b;
		int dis=abs(a-b)+x;
		cout<<min(n-1,dis)<<'\n';
	}
	return 0;
}
posted @ 2019-11-15 11:54  YuhanのBlog  阅读(49)  评论(0编辑  收藏  举报