社区讨论
为什么J组T2爆弹了啊555
灌水区参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lo1bk53r
- 此快照首次捕获于
- 2023/10/22 18:21 2 年前
- 此快照最后确认于
- 2023/10/22 19:30 2 年前
Kc code,帮忙看看吧,,,
CPP#include<bits/stdc++.h>
using namespace std;
int n,d;
long long now,fin;
int dis[100005];
int cost[100005];
int Read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
{
f=-1;
}
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
void Write(int x)
{
if(x<0)
{
x=-x;
putchar('-');
}
if(x>9)
{
Write(x/10);
}
putchar(x%10+'0');
}
int main()
{
// freopen("road.in","r",stdin);
// freopen("road.out","w",stdout);
n=Read(),d=Read();
for(int i=1;i<n;i++)//dis[i] means the distance from point i to point i+1
{
dis[i]=Read();
}
for(int i=1;i<n;i++)
{
cost[i]=Read();
}
int p=1,cz,jl=0;
while(p<n)
{
cz=n;
for(int i=p+1;i<n;i++)
{
if(cost[i]<cost[p])
{
cz=i;
break;
}
}
jl=0;
for(int i=p;i<cz;i++)
{
jl=jl+dis[i];
}
if(now>=jl)//can get there
{
now=now-jl;
}
else
{
//cout<<now<<" ";
now=jl+(d-(jl%d))-now;
//cout<<now<<" ";
fin=fin+now/d*cost[p];
now=now-jl;
}
//cout<<now/d*cost[p]<<" "<<jl<<" "<<p<<"\n";
p=cz;
}
cout<<fin;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...