Submission #529864

#TimeUsernameProblemLanguageResultExecution timeMemory
529864__VariattoDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //#include "molecules.h" using namespace std; #define pb push_back #define fi first #define se second #define ll long long const ll MAX=2e5+10; pair<ll,ll>t[MAX]; ll n, u, l; vector<ll>v; ll pref[MAX], suf[MAX]; vector<int> znajdz(ll k){ ll sum=pref[k-1]; vector<int>wy; for(ll i=0; i<k; i++) wy.pb(t[i].se); if(sum>=l && sum<=u) return wy; for(ll i=0; i<k; i++){ sum-=t[i].fi, sum+=t[n-i-1].fi; wy[i]=t[n-i-1].se; if(sum>=l && sum<=u) return wy; } return wy; } vector<int> find_subset(int l, int u, vector<int>w){ ll n=w.size(); for(ll i=0; i<n; i++){ t[i].fi=w[i]; t[i].se=i; } sort(t, t+n); for(ll i=0; i<n; i++){ pref[i]=t[i].fi; if(i) pref[i]+=pref[i-1]; } vector<int>wy; for(ll i=n-1; i>=0; i--) suf[i]=suf[i+1]+t[i].fi; for(ll k=1; k<=n; k++){ if(pref[k-1]<=u && suf[n-k]>=l){ wy=znajdz(k); sort(wy.begin(), wy.end()); return wy; } } return wy; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin>>n>>l>>u; vector<int>x; for(ll i=1; i<=n; i++){ ll c=0; cin>>c; x.pb(c); } vector<int>xd=find_subset(l, u, x); for(auto a:xd) cout<<a<<" "; cout<<"\n"; }

Compilation message (stderr)

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