codeforces 999D Equalize the Remainders
看做一个有向环
考虑我们其实从每个点出发如果采用最优策略那么一定都是一样的 那么不妨来看
我一遍扫描一边带着前缀和 如果遇到是小于平均值的我优先分配给他我最前面的
注意扫描一遍是不够的 但最多两遍即可 因为最优策略不可能绕一圈以上
#include#define ll long longusing namespace std;inline char gc(){ static char now[1<<16],*S,*T; if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;} return *S++;}inline int read(){ int x=0,f=1;char ch=gc(); while(!isdigit(ch)) {if (ch=='-') f=-1;ch=gc();} while(isdigit(ch)) x=x*10+ch-'0',ch=gc(); return x*f;}const int N=2e5+10;const int inf=0x3f3f3f3f;int n,m,s[N];vector q[N];queue pd;ll a[N],ans;inline void add(int p,int sta,int ed){ if(stad) {pd.push(st);++st;st%=m;continue;} if (q[st].size()d&&q[st].size()
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~