Submission #1115318

# Submission time Handle Problem Language Result Execution time Memory
1115318 2024-11-20T10:28:56 Z komasan Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

#define fi first
#define se second

template<class A, class B> inline bool maximize(A& x, B y) {
    if (x < y) {
        x = y;
        return true;
    } else
        return false;
};

template<class A, class B> inline bool minimize(A& x, B y) {
    if (x > y) {
        x = y;
        return true;
    } else
        return false;
};

vector<int> find_subset(int l, int r, vector<int> a) {
    vector<pair<int, int>> p;
    for (int i = 0; i < (int)a.size(); i++)
        p.push_back(make_pair(a[i], i + 1));

    sort(p.begin(), p.end());

    int sum = 0, j = 0;
    for (int i = 0; i < (int)p.size(); i++) {
        sum += p[i].fi;

        while (sum > r)
            sum -= p[j++].fi;
        
        if (sum >= l) {
            vector<int> ans;
            for (int k = j; k <= i; k++)
                ans.push_back(p[k].se);

            sort(ans.begin(), ans.end());

            return ans;
        }
    }

    return {};
}

void komasan() {
    vector<int> ans = find_subset(15, 17, {6, 8, 8, 7});
    for (int x : ans)
        cout << x << ' ';
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    // freopen(".inp", "r", stdin);
    // freopen(".out", "w", stdout);
    
    komasan();
}

Compilation message

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