Fair Work Load [Top Coder]

This problem was used for: (@ Top coder) Single Round Match 169 Round 1 – Division I, Level Two Single Round Match 169 Round 1 – Division II, Level Three Problem Link class FairWorkload{ public: int getMostWork(vector<int> folder,int worker) { int n = folder.size(); int lw = *max_element(folder.begin(),folder.end()); int hi = accumulate(folder.begin(),folder.end(),0); int mid_load; int

880

#include <iostream> #include <cstdio> #define ul unsigned long long #define INT_MX 2147483641 using namespace std; ul binsearch(ul n,ul lw,ul hi) { ul mid; ul tmp,tmp1,tmp2; while(lw<hi) { mid=(lw+hi)/2; tmp = (mid*(mid+1))/2; if(tmp<=n) lw=mid+1; else if(tmp>n) hi=mid; } return hi; } int main() { ul n; ul diff,hi,lw; ul neumenator,denominator; while(cin>>n) { hi = binsearch(n,0,INT_MX); diff

10494

#include <iostream> #include <cstdio> #include <cstring> //#include <fstream> #define ul unsigned long long using namespace std; int quotient[10005]; ul remainder; int main() { char num[10005]; char op[2]; int div; int pos; int j,k; //ofstream out; //out.open("out_10494.txt"); while(scanf("%s%s%d",num,op,&div)!=EOF) { k=0; remainder=0; for(int i=0;i<strlen(num);i++) { quotient[k] = 0; remainder = remainder*10+(num[i]-'0'); quotient[k] = remainder/div; remainder = remainder%div;

10611

#include <iostream> #include <cstdio> #include <cstring> using namespace std; int arr[50005]; int binSearch(int num,int lw,int hi) { int mid; while(lw<hi) { mid = (hi+lw)/2; if(num<arr[mid]) hi = mid; else if(num>=arr[mid]) lw = mid+1; } return hi; } int main() { int N,Q,a; int len,qry,idx; while(scanf("%d",&N)!=EOF) { scanf("%d",&arr[0]); len = 1; for(int i=1;i<N;i++) { scanf("%d",&a); if(a!=arr[len-1])