71952024-01-03 12:37:11MagyarKendeSZLGBányász RPG (40 pont)cpp17Time limit exceeded 9/40400ms5896 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;

int xp, t;

struct Material {
public:
    int upgrade;
    int get;
    bool profiting;
    
    Material() : upgrade(0), get(0), profiting(0) {}
    Material(int u, int g) : upgrade(u), get(g), profiting(g - u > 0) {}

    static bool fastmine(Material m) {
        return m.upgrade <= xp;
    }

    bool operator()(Material a, Material b) {

        if (fastmine(a) || fastmine(b)) {
            return fastmine(a) < fastmine(b);
        }

        if (a.profiting || b.profiting) {
            return a.profiting < b.profiting;
        }

        return a.upgrade > b.upgrade;
    }
};

int main() {
    speed;

    int N;
    cin >> N;
    vector<int> upS(N), getS(N);

    cinv(upS);
    cinv(getS);
    
    priority_queue<Material, vector<Material>, Material> pq;
    
    while (N--) {
        pq.push({upS[N], getS[N]});
    }

    while (!pq.empty()) {
        Material next = pq.top();
        pq.pop();

        if (next.get == 0) continue;

        t += 2 - Material::fastmine(next);
        next.get--;
        xp++;

        pq.push(next);
    }

    cout << t;
}
SubtaskSumTestVerdictTimeMemory
base9/40
1Accepted0/03ms2104 KiB
2Time limit exceeded0/0400ms2288 KiB
3Accepted2/24ms2532 KiB
4Accepted2/237ms2820 KiB
5Time limit exceeded0/2370ms2664 KiB
6Time limit exceeded0/2374ms2908 KiB
7Accepted2/2165ms3236 KiB
8Time limit exceeded0/2367ms2704 KiB
9Accepted3/33ms3320 KiB
10Wrong answer0/34ms3432 KiB
11Wrong answer0/38ms3624 KiB
12Wrong answer0/3152ms3984 KiB
13Time limit exceeded0/4365ms3908 KiB
14Time limit exceeded0/4370ms4020 KiB
15Time limit exceeded0/2382ms4928 KiB
16Time limit exceeded0/2367ms5768 KiB
17Time limit exceeded0/2370ms5136 KiB
18Time limit exceeded0/2374ms5896 KiB