Submission #960219

# Submission time Handle Problem Language Result Execution time Memory
960219 2024-04-09T23:44:50 Z RyaroX Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

/*int[] find_subset(int l,int u,int[] w){

}*/
ll dp[20005];
int main()
{
    //ifstream cin("in.in");
    ll n,l,u;
    cin>>n>>l>>u;
    ll d=0;
    dp[0]=1;
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        for(ll j=0;j<u;j++){
            if(dp[j]>0){
                dp[j+a]=a;
                if(j+a>=l and j+a<=u){
                    ll s=j+a;
                    vector <ll> V;
                    while(s>0){
                        //cout<<s<<" "<<dp[s]<<"\n";
                        V.push_back(dp[s]);
                        s=s-dp[s];
                    }
                    reverse(V.begin(), V.end());
                    for(auto i:V) cout<<i<<" ";
                    return 0;
                }
            }

        }
    }
}

Compilation message

molecules.cpp: In function 'int main()':
molecules.cpp:15:8: warning: unused variable 'd' [-Wunused-variable]
   15 |     ll d=0;
      |        ^
/usr/bin/ld: /tmp/ccRIq0oR.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDNFDGP.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccRIq0oR.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status