<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Educational Codeforces Round 76 (Rated for Div. 2) A. Two Rival Students 水題

      A. Two Rival Students

      There are ?? students in the row. And there are two rivalling students among them. The first one is in position ??, the second in position ??. Positions are numbered from 1 to ?? from left to right.

      Since they are rivals, you want to maximize the distance between them. If students are in positions ?? and ?? respectively, then distance between them is |?????|.

      You can do the following operation at most ?? times: choose two adjacent (neighbouring) students and swap them.

      Calculate the maximum distance between two rivalling students after at most ?? swaps.

      Input

      The first line contains one integer ?? (1≤??≤100) — the number of test cases.

      The only line of each test case contains four integers ??, ??, ?? and ?? (2≤??≤100, 0≤??≤100, 1≤??,??≤??, ??≠??) — the number of students in the row, the number of swaps which you can do, and positions of first and second rivaling students respectively.

      Output

      For each test case print one integer — the maximum distance between two rivaling students which you can obtain.

      Example

      input
      3
      5 1 3 2
      100 33 100 1
      6 0 2 3
      output
      2
      99
      1

      Note

      In the first test case you can swap students in positions 3 and 4. And then the distance between the rivals is equal to |4?2|=2.

      In the second test case you don't have to swap students.

      In the third test case you can't swap students.

      題意

      現在有n個東西排列成一行,a在第a個位置,b在第b個位置,現在每次操作可以使得一個人和周圍的人交換位置,問你在操作最多x次的情況下,最多能夠使得a和b的距離最遠是多少

      題解

      每次交換一次,肯定可以使得距離加一,那么答案就是要么就最遠,要么就當前的距離+x即可。

      代碼

      #include<bits/stdc++.h>
      using namespace std;
      
      void solve(){
      	int n,x,a,b;
      	cin>>n>>x>>a>>b;
      	if(a>b)swap(a,b);
      	cout<<min(b-a+x,n-1)<<endl;
      }
      int main(){
      	int t;cin>>t;
      	while(t--)solve();
      }
      
      posted @ 2019-11-14 17:46  qscqesze  閱讀(406)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 97视频精品全国免费观看| 视频一区视频二区卡通动漫| 国产激情一区二区三区成人| 亚洲一区二区三区在线播放无码| 国产99在线 | 亚洲| 18av千部影片| AV免费播放一区二区三区| 毕节市| 亚洲精品无码av天堂| 国产免费无遮挡吃奶视频| 97亚洲色欲色欲综合网| 乱码精品一区二区亚洲区| 日本五十路熟女一区二区| 成人影片一区免费观看| 久久精品国产亚洲av麻| 九九热在线精品视频99| 国产午夜精品久久久久免费视| 99视频在线精品国自产拍| 日本中文字幕一区二区三| 丰满人妻一区二区三区无码AV| 亚洲精品www久久久久久| 久久夜色精品亚洲国产av| 国产微拍一区二区三区四区| 色欲AV无码一区二区人妻| 国产午夜福利在线观看播放| 亚洲精品麻豆一二三区| 国产亚洲av手机在线观看| 免费看亚洲一区二区三区| 四虎影视久久久免费| 亚洲一区二区三区十八禁| 精品国偷自产在线视频99| 达日县| 亚洲av成人午夜福利| 无码国产成人午夜电影在线观看| 一级做a爰片在线播放| 精品亚洲国产成人性色av| 日韩欧美aⅴ综合网站发布| 韩国精品一区二区三区在线观看| 亚洲无线码中文字幕在线| 午夜福制92视频| 丰满熟妇人妻中文字幕|