社区讨论
CSP-J T2洛谷和小图灵估分反差巨大
学术版参与者 9已保存回复 11
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 10 条
- 当前快照
- 1 份
- 快照标识符
- @lo03tt12
- 此快照首次捕获于
- 2023/10/21 21:57 2 年前
- 此快照最后确认于
- 2023/11/02 12:06 2 年前
同样的代码小图灵 85pts,洛谷 5pts ?大概CCF数据下有多少分
CPP#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll in(){
ll 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<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*f;
}
ll n,d,v[100005],a[100005],cnt,tmp=1,tot,ans;
int main(){
//freopen("road.in","r",stdin);
//freopen("road.out","w",stdout);
n=in(),d=in();
for (int i=1;i<n;i++)v[i]=in();
for (int i=1;i<=n;i++)a[i]=in();
for (int i=2;i<=n;i++){
tot+=v[i-1];
if (a[i]>a[tmp])continue;
if (tot<0){tmp=i;continue;}
int x;
if (tot%d==0)x=tot/d;
else x=tot/d+1;
ans+=x*a[tmp];
tot=tot-x*d;
tmp=i;
}
if (tmp!=n){
if (tot>0){
int x;
if (tot%a[tmp]==0)x=tot/a[tmp];
else x=tot/a[tmp]+1;
ans+=x*a[tmp];
}
}
printf ("%lld",ans);
return 0;
}
回复
共 11 条回复,欢迎继续交流。
正在加载回复...