比赛 |
防止浮躁的小练习v0.4 |
评测结果 |
AAAAAAAAAA |
题目名称 |
走出金字塔 |
最终得分 |
100 |
用户昵称 |
NVIDIA |
运行时间 |
0.010 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2016-10-13 17:45:33 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int get(int x1,int y1,int x2,int y2)
{
int d=(x2-x1)*2-(y1%2);
int pymin=y1+(y1%2),pymax=y1+(x2-x1)*2-(y1%2);
if (pymin>y2)
d+=(pymin-y2);
else if (pymax<y2)
d+=(y2-pymax);
return d;
}
int main()
{
freopen("ha14c.in","r",stdin);
freopen("ha14c.out","w",stdout);
int n,m,k,s;
scanf("%d%d%d%d",&n,&m,&k,&s);
int ans=(1<<30);
int xa,ya;
scanf("%d%d",&xa,&ya);
for (int i=0;i<m;i++)
{
int xi,yi;
scanf("%d%d",&xi,&yi);
if (xi<xa)
ans=min(ans,get(xi,yi,xa,ya));
if (xi==xa)
ans=min(ans,abs(ya-yi));
if (xi>xa)
ans=min(ans,get(xa,ya,xi,yi));
}
if (k*ans+1<=s)
cout<<s-(k*ans+1)<<endl;
else
cout<<-1<<endl;
return 0;
}