版本比较
题解:P15573 [USACO26FEB] Clash! S
正文
增加 6 行删除 6 行
40 行未改动4142434445454647484946 行未改动969798991001001011021021031041051061071081091101101111121131141151161171171181191201211221221231241251263 行未改动40 行未改动
## AC code:
```// AC代码 QwQ // AC代码 QwQ
#include<bits/stdc++.h>#define int long longusing namespace std;46 行未改动 sum+=min_ml; handvis[card]=0; ml[++cnt]=sum; q.push(card); }else{ }else{ // 没有胜利牌 →打普通牌 while(!handvis[hand.top().second]) hand.pop();// 清除堆里已不在的手牌(这一步非常关键,不加必废) while(!handvis[hand.top().second]) hand.pop();// 清除堆里已不在的手牌(这一步非常关键,不加必废) int min_ml=hand.top().first; int card=hand.top().second; hand.pop(); handvis[card]=0; sum+=a[card]; q.push(card); } // 补手牌 // 补手牌 int tmp=q.front(); q.pop(); handvis[tmp]=1; hand.push(make_pair(a[tmp],tmp)); if(vis[tmp]) handwin.push(make_pair(a[tmp],tmp)); } ml[cnt+1]=0x3f;// 防止二分越界 ml[cnt+1]=0x3f;// 防止二分越界 qq=read(); int x=0; while(qq--){ x=read(); int shengyu=upper_bound(ml+1,ml+1+cnt,x%sum)-ml-1;// 二分找剩余部分能打出多少胜利牌 int shengyu=upper_bound(ml+1,ml+1+cnt,x%sum)-ml-1;// 二分找剩余部分能打出多少胜利牌 cout<<x/sum*cnt+shengyu<<"\n"; } return 0;}3 行未改动