80分求助,测试点2wa
查看原帖
80分求助,测试点2wa
1414756
lwj200623楼主2025/1/19 02:23
#include<iostream>
#include<map>
#include<iomanip>
using namespace std;

int main()
{
	double n, t; cin >> n >> t;
	map<long double, pair<double,double>>arr;
	for (int i = 0; i < n; i++)
	{
		double m, v; cin >> m >> v;
		arr.insert(make_pair(v / m, make_pair(m,v)));
	}
	double c1 = 0; double c2 = 0;
	auto brr = arr.rbegin();
	for (brr; brr != arr.rend(); ++brr)
	{
		double m = brr->second.first, v = brr->second.second;
		if (c1+m <= t)
		{
			c1 += m; c2 += v;
		}
		else
		{
			c2 += (t - c1) * brr->first; break;
		}
	}
	cout << setprecision(2) << fixed << c2;

	return 0;
}
2025/1/19 02:23
加载中...