比赛 2026.9.5 评测结果 WWWWWWWWWWWWWWWWWWWWWWWAW
题目名称 Asteroid Mining 最终得分 4
用户昵称 终焉折枝 运行时间 6.988 s
代码语言 C++ 内存使用 10.38 MiB
提交时间 2026-09-05 12:56:15
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using f64 = double;
using f128 = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi  = vector<int>;
using vll = vector<ll>;

#define pb emplace_back
#define mk make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define ciallo(x) cerr << (x) << '\n';

template <typename T, typename U>
inline bool chmin(T& a, const U& b){return (b < a ? a = b, true : false);}
template <typename T, typename U>
inline bool chmax(T& a, const U& b){return (a < b ? a = b, true : false);}

const int MAXN = 5 * 1e5 + 5;
int N, M;
struct node{
    ll v, m;
    long double fiv;
}k[MAXN];
bool vis[MAXN];

inline void solve(){
    cin >> N >> M;
    for(int i = 1;i <= N;i ++){
        cin >> k[i].v >> k[i].m;
        k[i].fiv = (1.0 * k[i].v * 1.0) / (1.0 * k[i].m * 1.0);
//        printf("%.6lf\n", k[i].fiv);
    }
    sort(k + 1, k + N + 1, [](const node &x, const node &y){
        return x.fiv > y.fiv;
    });
    int ans = 0;
    for(int i = 1;i <= N;i ++){
        if(M - k[i].m >= 0){
            ans += k[i].v;
            M -= k[i].m;
        }
    }
    cout << ans << '\n';
}

int main(){
    freopen("Mining.in", "r", stdin);
    freopen("Mining.out", "w", stdout);
    cin.tie(0) -> ios::sync_with_stdio(0);
    int T = 1;
    while(T --) solve();
//    #ifdef LOCAL
//        cout << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n ";
//    #endif
    return 0;
}