Submission #1282092

#TimeUsernameProblemLanguageResultExecution timeMemory
1282092lukasuliashviliFestival (IOI25_festival)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> max_coupons(long long A, vector<long long>& P, vector<int>& T) {
    int N = (int)P.size();
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](int i, int j){
        if (P[i] != P[j]) return P[i] < P[j];
        return T[i] > T[j];
    });
    long long tokens = A;
    vector<bool> used(N,false);
    vector<int> result;
    int pos = 0;
    priority_queue<pair<int,int>> pq;
    while (true) {
        while (pos < N && P[idx[pos]] <= tokens) {
            int i = idx[pos];
            pq.emplace(T[i], i);
            pos++;
        }
        if (pq.empty()) break;
        auto [mult, i] = pq.top();
        pq.pop();
        if (used[i]) continue;
        used[i] = true;
        result.push_back(i);
        tokens = (tokens - P[i]) * mult;
    }
    return result;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long A;
    int N;
    cin >> A >> N;
    vector<long long> P(N);
    vector<int> T(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> T[i];
    vector<int> R = max_coupons(A, P, T);
    cout << R.size() << "\n";
    for (int i = 0; i < (int)R.size(); i++) {
        if (i) cout << " ";
        cout << R[i];
    }
    cout << "\n";
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccAXg9ar.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccakv0lR.o:festival.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccAXg9ar.o: in function `main':
grader.cpp:(.text.startup+0x22a): undefined reference to `max_coupons(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status