寒假刷題36:Codeforces Round #622 (Div. 2) B. Different Rules

題目鏈接:

Codeforces Round #622 (Div. 2) B. Different Rules

題目解析:

這次B題好像坑了不少人,最後過的人數還沒C1多(讓本菜雞恰了一波爛分)

結論:〈max(1,min(n,x+y−n+1)),min(n,x+y−1)〉

這裏有詳細分類討論過程 http://codeforces.com/blog/entry/74146 和我當時分類思想類似,就不再班門弄斧了

AC代碼:

#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define ll long long
 
ll t,n,x,y;
ll ans1,ans2;
int main()
{
   cin>>t;
   while(t--)
   {
       cin>>n>>x>>y;
       //if(x>y) swap(x,y);
       ll t=x+y-n;
       if(t<=0) ans1=1;
       else ans1=min(t+1,n);
 
       ans2=min(x+y-1,n);
       cout<<ans1<<" "<<ans2<<endl;
   }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章