50pts
查看原帖
50pts
930686
Forge_Unique楼主2024/4/12 14:42
#include<map>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define _ 0
#define int long long
#define pii pair <int,int>
#define fx first
#define fy second
using namespace std;
const int N = 10010;
int m,n,k,cnt;
struct stone{
	int v,w;
	double q;
}a[N];
bool cmp(stone x,stone y){
	return x.q >= y.q;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin >> m >> n >> k;
	for(int i = 0;i < n;i++){
		cin >> a[i].v >> a[i].w;
		a[i].q = a[i].v * 1.0 / a[i].w;
	}
	sort(a,a + n,cmp);
	while(true){
		if(cnt == n + 10){
			cout << "Impossible";
			break;
		}
		if(m <= 0){
			cout << k;
			break;
		}
		if(k <= 0){
			cout << "Impossible";
			break;
		}
		if(k >= a[cnt].w){
			k -= a[cnt].w;
			m -= a[cnt].v;
		}
		cnt++;
	}
	return ~~(0^_^0);
	cout << "114514";
}
2024/4/12 14:42
加载中...