WA一个点
  • 板块学术版
  • 楼主llxsmy_forever
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/11/30 09:21
  • 上次更新2023/10/27 00:57:24
查看原帖
WA一个点
664779
llxsmy_forever楼主2022/11/30 09:21
#include<bits/stdc++.h>
#define dou double
using namespace std;
dou d1,c,d2,p;
int n;
struct node{dou d,pr;}a[10];
bool cmp(node n1,node n2){return (n1.d==n2.d)?n1.pr<n2.pr:n1.d<n2.d;}
dou ans;
void dfs(int id)
{
	dou maxn=a[id].d+c*d2;
	bool bk=(maxn>=d1)?1:0,v=0;
	for(int i=id+1;i<=n;i++)
	{
		if(a[i].d<=maxn)
		{
			if(a[i].pr<a[id].pr||(!bk&&a[i+1].d>maxn))
			{
				ans+=(a[i].d-a[id].d)/d2*a[id].pr;
				v=1;dfs(i);
				break;
			}
		}
		else break;
	}
	if(!v&&bk) ans+=(d1-a[id].d)/d2*a[id].pr;
}
int main()
{
	scanf("%lf%lf%lf%lf%d",&d1,&c,&d2,&p,&n);
	for(int i=1;i<=n;i++) scanf("%lf%lf",&a[i].d,&a[i].pr);
	sort(a+1,a+1+n,cmp);a[0]={0,p};
	if(a[n].d+c*d2<d1)
	{
		printf("No Solution");
		return 0;
	}
	ans=0;dfs(0);
	printf("%.2f",ans);
	return 0;
}

P1016

2022/11/30 09:21
加载中...