CSP-J T2求调
  • 板块学术版
  • 楼主ArisakaMashiro
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/10/21 22:16
  • 上次更新2023/11/2 12:05:47
查看原帖
CSP-J T2求调
1067742
ArisakaMashiro楼主2023/10/21 22:16
#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;
}

洛谷80pts,小图灵25pts,但是全用long long后也只有85/50pts,有哪里写错了吗?求大佬指正Orz

2023/10/21 22:16
加载中...