- 守望者的逃离
- 2015-09-23 19:28:11 @
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int M,S,T;
int ANS=1e9;
int MOVE;
int main(){
scanf("%d%d%d",&M,&S,&T);
for(int i=1;i<=T;i++){
int tim=i;
int move=60*i;
int tot=10*i;//需要的魔法点数
if(tot>M){//计算需要休息的时间
int delta=tot-M;
double x1=double(delta)/(double)(4);
int x2=int(x1);
if(x1>double(x2)) x2++;
tim+=x2;
}
if(tim<=T&&move>=S){
ANS=min(ANS,tim);
continue;
}
int s=S-move;//需要走的路程
if(s<=0) continue;
double t1=double(s)/(double)(17);
int t2=int(t1);
if(t1>double(t2)) t2++;
tim+=t2;
if(tim<=T){
ANS=min(ANS,tim);
continue;
}
else if(ANS==1e9){
int t3=T-(tim-t2);
move+=t3*17;
MOVE=max(MOVE,move);
}
}
if(ANS==1e9){
cout<<"No"<<endl;
cout<<MOVE<<endl;
}
else{
cout<<"Yes"<<endl;
cout<<ANS<<endl;
}
return 0;
}
枚举使用魔法的次数,更新答案
1 条评论
-
神的崛起 LV 10 @ 2015-10-06 22:33:58
有必要吗,直接贪心不就得了,亏我还以为这道题要用转移方程,推了半天都没出来,醉了。
var
i,a,j,k,o,p,n,m,s,t,b:longint;
f:Array[0..10000]of longint;
begin
readln(m,s,t);
for i:=1 to t do
begin
inc(a,17);
if m>=10 then
begin
dec(m,10);
inc(b,60);
end
else begin
inc(m,4);
end;
if a<b then a:=b;
if a>=s then
begin
writeln('Yes');
writeln(i);
close(output);
close(input);
halt;
end;
end;
writeln('No');
write(a);
end.
- 1