2009-05-22
SRM229 Div1 Easy: Cafeteria
Algorithm Tutorials: How To Find a Solution (by Dumitru) より。Brute Forceで解く例(その3)。
- 数があわないと思ったら、いちばん速いバス停を求めていたorz
- 直した
- 210.60points (12'47''), Passed System Test
- なんか遅いなあ>自分
class Cafeteria {
string twelve(int min){
int h=min/60, m=min%60;
if (h>12) h-=12;
char buf[6];
sprintf(buf,"%02d:%02d",h,m);
return buf;
}
public:
string latestTime(vector <int> offset, vector <int> walkingTime, vector <int> drivingTime) {
int n=sz(offset);
int lim=60*14+30;
int latest=0;
rep(i,n){
int o=offset[i],// 0-9
wt=walkingTime[i],//1-30
dt=drivingTime[i];//1-300
int lastdep=lim-dt, lastdepo=lastdep%10, lastdep0 = lastdep-lastdepo;
int busdep= (o<=lastdepo)? (lastdep0+o) : (lastdep0-10+o);
int dep=busdep-wt;
latest >?= dep;
}
return twelve(latest);
}
};
コメント
トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20090522