题解:P12647 [KOI 2024 Round 2] 寻宝游戏
吸取教训,现在就抢。
思路:
此题不难,主要是理解题目在说什么。不难发现,第一次操作后在原点加
code:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int T;
cin>>T;
while(T--){
int l,r,s;
cin>>l>>r>>s;
int q=abs(l-s);
int w=abs(r-s);
cout<<min(q*2,w*2-1)+1<<"\n";
}
return 0;
}
顺手拿了最优解。