编译错误?
  • 板块灌水区
  • 楼主DeepSeekV3
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/10/5 17:09
  • 上次更新2023/11/2 15:28:00
查看原帖
编译错误?
907408
DeepSeekV3楼主2023/10/5 17:09
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 5;
struct node{
	int x, y;
	double z;
}a[N];

bool cmp(node n, node m)
{
	if (n.z != m.z)
	{
		return n.z < m.z;
	}
	else
	{
		return n.x < m.x;
	}
}

int main()
{
	int m, n;
	cin >> m >> n;
	for (int i = 1; i <= m; i++)
	{
		cin >> a[i].x >> a[i].y;
		a[i].z = 1.0 * (a[i].x / a[i].y);
	}
	
	sort(a + 1, a + m + 1);
	int sum = 0;
	
	for (int i = 1; i <= m; i++)
	{
		if (n >= a[i].x)
		{
			n -= a[i].x;
			sum += a[i].y;
		}
		else
		{
			cout << sum << endl;
			return 0;
		}
	}
	return 0;
}

2023/10/5 17:09
加载中...