求调
查看原帖
求调
1067742
ArisakaMashiro楼主2023/11/1 23:03
#include<bits/stdc++.h>
int num = 1, per = 1, now = 1, last = 0, distance[120000], price[120000], buy = 0;
long double oil = 0l, tem = 0l, going = 0;
long long cost = 0;
int main(){
	std::cin >> num >> per;
	for(int i = 2; i <= num; i++){
		std::cin >> distance[i];
	}
	for(int i = 1; i <= num; i++){
		std::cin >> price[i];
	}
	last = now;
	while(now < num){
		now++;
		going += distance[now];
		if(now == num || price[now] < price[last]){
			tem = going / per;
			tem -= oil;
			oil = 0;
			buy = tem / 1;
			if(tem - buy != 0){
				buy++;
			}
			cost += buy * price[last];
			oil = buy - tem;
			last = now;
			going = 0;
		}
	}
	std::cout << cost;
	return 0;
}

简单贪心思路

Luogu80Pts,官方85pts,不知道哪里错了,可以给Hack或者直接指正,谢谢各位大佬

2023/11/1 23:03
加载中...