思维路径
容易注意到,这个赛制对于 BaoBao 非常不友好,因为 DreamGrid 可以通过他出的牌来决定自己的出牌。也就是说,我们不需要关注 BaoBao 的出牌顺序,只需要关注他出的每一张牌对应 DreamGrid 出的牌即可。
对于 DreamGrid 来说,对于 BaoBao 的每一张牌,他优先选择得 \(1\) 分的,然后是不得分的,最后是得 \(-1\) 分的。
由此我们就很容易可以得到做法,即先把能得 \(1\) 分得算出来,然后是不得分的,最后是得 \(-1\) 分的。
AC 代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll T;
ll dr,dp,ds,br,bp,bs;void input(){cin>>T;
}void solve(){cin>>br>>bp>>bs;cin>>dr>>dp>>ds;ll ans=0;ll x=0;//这边用x纯粹为了方便复制//得1分的部分x=min(dr,bs);ans+=x;dr-=x; bs-=x;x=min(dp,br);ans+=x;dp-=x; br-=x;x=min(ds,bp);ans+=x;ds-=x; bp-=x;//不得分的部分x=min(dr,br);dr-=x; br-=x; x=min(dp,bp);dp-=x; bp-=x;x=min(ds,bs);ds-=x; bs-=x;//得-1分得部分x=min(dr,bp);ans-=x;dr-=x; bp-=x;x=min(dp,bs);ans-=x;dp-=x; bs-=x;x=min(ds,br);ans-=x;ds-=x; br-=x;cout<<ans<<"\n";
}int main(){input();while(T--)solve();return 0;
}