Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3), problem: (E) Prairie Partition Solution In C/C++

By | 2017-07-24T02:37:16+00:00 July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<bits/stdc++.h> using namespace std; int n; long long a[100005]; int check(int x){ int i,j,res,ress,t,sum; long long A,AA; i=0;ress=0; for(j=0;j<60;j++){ A=(1LL<<j); res=0; for(;i<n;i++){ if(a[i]==A){ res++; } else if(a[i]<A){ ress++; } else break; } if(ress>x) return 0; if(x>res){ ress-=(x-res); if(ress<0) ress=0; x=res; } if(res>x) ress+=(res-x); } [...]