P1016样例炸了求助
查看原帖
P1016样例炸了求助
1436254
xingjielongSYH楼主2025/2/7 20:07
#include<bits/stdc++.h>
using namespace std;
int n,mn[10];
double d1,d2,c,p,d[10],v[10],now=0,ans=0;
int main(){
	cin >> d1 >> c >> d2 >> p >> n;
	d[0]=0,v[0]=p;
	d[n+1]=d1,v[n+1]=1e9;
	for(int i=1;i<=n;i++){
		cin >> d[i] >> v[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=i+1;j<=n+1;j++){
			if(v[j]<v[i]){mn[i]=j;break;}
		}
	}
	for(int i=0;i<=n;i++){
		int tmp=(d[mn[i]]-d[i])/c;
		if(tmp>d2){
			if((d[i+1]-d[i])/c>d2){
				cout << "No Solution" << endl;
			}
			else tmp=d2;
		}
		ans+=max(0.0,tmp-now)*v[i];
		now=tmp;
		now=max(.0,now-(d[i+1]-d[i])/c);
	}
	cout << ans;
	return 0;
}

链接 样例输出:50.4

2025/2/7 20:07
加载中...