CSP-J T2洛谷和小图灵估分反差巨大
  • 板块学术版
  • 楼主ryf_loser
  • 当前回复10
  • 已保存回复11
  • 发布时间2023/10/21 21:56
  • 上次更新2023/11/2 12:06:38
查看原帖
CSP-J T2洛谷和小图灵估分反差巨大
761649
ryf_loser楼主2023/10/21 21:56

同样的代码小图灵 85pts,洛谷 5pts ?大概CCF数据下有多少分

#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;
}

2023/10/21 21:56
加载中...