CSP-J考前抱佛脚求助,除了1,2,4,5,9全WA
查看原帖
CSP-J考前抱佛脚求助,除了1,2,4,5,9全WA
947202
wangruize88楼主2024/10/7 19:06
#include <iostream>
#include <cmath>
using namespace std ;
typedef long long LL ;
LL v[100001] , a[100001] , n , d ;
long double ans , oil ;
LL fun ( LL s ) {
	LL l = 0 , next_s = s+1 , i = s+1 ;
	while ( i<=n ) {
		//cout << s << ' ' << i << ' ' << a[s] << ' ' << a[i] << endl ;
		l += v[i] , next_s = i , i++ ;
		if ( a[i-1]<a[s] ) break ;
	}
	//cout << endl << "<>---" << s << ' ' << next_s << ' ' << l << ' ' << ceil((l*1.0-oil*d)/(d*1.0)) << endl ;
	ans += ceil((l*1.0-oil*d)/(d*1.0))*a[s] ;
	oil = oil+ceil((l*1.0-oil*d)/(d*1.0))-(l*1.0)/(d*1.0);
	return next_s ;
}
int main () {
	cin >> n >> d ;
	for ( LL i = 2 ; i <= n ; i++ ) cin >> v[i] ;
	for ( LL i = 1 ; i <= n ; i++ ) cin >> a[i] ;
	int m = 1 ;
	while ( m < n ) {
		m = fun(m) ;
	}
	cout << ans ;
	return 0 ;
}
2024/10/7 19:06
加载中...