2008-12-26
SRM395 Div1 Easy: StreetWalking
これは速解き問題。Test Caseが親切。(斜め/\に進んだほうが速いケースとか)
class StreetWalking { public: long long minTime(int X, int Y, int walkTime, int sneakTime) { if(X>Y)swap(X,Y); long long a=Y-X, b=X, h=a/2, m=a%2; long long t = min(b*2*walkTime, b*sneakTime) + min(a*walkTime, h*2*sneakTime+m*walkTime); return t; } };