Submission #1325967

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

struct El {
    int p, idx;
};

vector<int> max_coupons(int a, vector<int> p, vector<int> t){
    int n = (int)p.size();
    vector<El> ones, twos;
    for(int i = 0; i < n; i++){
        if(t[i] == 1) ones.push_back({p[i], i});
        else twos.push_back({p[i], i});
    }

    sort(ones.begin(), ones.end(), [&](auto l, auto r){ return l.p < r.p; });
    sort(twos.begin(), twos.end(), [&](auto l, auto r){ return l.p < r.p; });

    int curr = a, pos1 = -1, pos2 = -1;
    for(int i = 0; i < (int)twos.size(); i++){
        curr = 2*(curr - twos[i].p);
        if(curr < 0) break;
        int curr2 = curr;
        for(int j = 0; j < (int)ones.size(); j++){
            if(curr2 - ones[j].p < 0) break;
            curr2 -= ones[j].p;
            if(i + j + 2 > pos1 + pos2 + 2){
                pos2 = i;
                pos1 = j;
            }
        }
    }

    vector<int> sol;
    for(int i = 0; i <= pos2; i++) sol.push_back(twos[i].idx);
    for(int i = 0; i <= pos1; i++) sol.push_back(ones[i].idx);

    return sol;
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    vector<int> ans = max_coupons(13, {4, 6, 8, 14}, {1, 1, 2, 2});
    for(auto &i : ans) cout << i << " ";
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cccaiJpj.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccciOhiJ.o:festival.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status