服了,30pts
  • 板块P6024 机器人
  • 楼主Max_hmt
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/16 22:05
  • 上次更新2024/7/17 08:31:08
查看原帖
服了,30pts
1397857
Max_hmt楼主2024/7/16 22:05

wa了

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> w(n), p(n), idx(n);
    for (int i = 0; i < n; ++i)
        cin >> w[i];
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i];
        idx[i] = i + 1;
    }
    sort(idx.begin(), idx.end(), [&](int a, int b)
        {
        return 1LL * w[a - 1] * (10000 - p[b - 1]) < 1LL * w[b - 1] * (10000 - p[a - 1]);
        });

    bool possible = true;
    long long st = 0,bfc = 1e18;
    for (int i = 0; i < n; ++i) {
        st += w[idx[i] - 1];
        bfc = std::min(bfc, st + w[idx[i] - 1]);
        if (p[idx[i] - 1] == 10000) {
            possible = false;
        }
    }

    if (!possible || bfc > 1e17)
        cout << "Impossible" << std::endl;
    else {
        for (int i = 0; i < n; ++i)
            cout << idx[i] << " ";
        cout << endl;
    }
    return 0;
}

2024/7/16 22:05
加载中...