SRM 414 DIV1 Easy - Embassy

問題


http://community.topcoder.com/stat?c=problem_statement&pm=9895&rd=13505

解き方


スタート地点によって待ち時間は異なるので、
すべてのスタート地点においてシミュレーションし、最短となる
時間が答えとなる。

コード


class Embassy {

public: int visaApplication(vector<int> forms, int dayLength, int openTime) {
int ret=1e+9;
int n=forms.size();

for(int s=0;s<=1000000;s++){
int tmp=0;
FORE(i,0,n){
tmp+=forms[i];
if( ((tmp-s)%dayLength+dayLength)%dayLength<=openTime)continue;
tmp+=dayLength-((tmp-s)%dayLength+dayLength)%dayLength;
}
ret=min(ret,tmp);
}

return ret;
}

};

Share this

Related Posts

Previous
Next Post »