Submission #260423

#TimeUsernameProblemLanguageResultExecution timeMemory
260423Bill_00Detecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms384 KiB
#include "molecules.h" #include <bits/stdc++.h> #define mp make_pair #define ff first #define ss second #define ll long long using namespace std; pair<int,int>p[200002]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=w.size(); for(int i=1;i<=n;i++){ p[i]=mp(w[i-1],i-1); } sort(p+1,p+n+1); vector<int>res; ll sum=0,id=0; for(int i=1;i<=n;i++){ sum+=p[i-1].ff; if(sum>=l && sum<=u){ for(int j=1;j<=i;j++){ res.push_back(p[i-1].ss); } return res; } if(sum>=l){ sum-=p[i-1].ff; id=i-1; break; } } //cout << id << endl; if(id==0){ return res; } for(int i=id;i>=1;i--){ sum=sum-p[i-1].ff; sum=sum+p[i+n-id-1].ff; //cout << sum << endl; if(sum>=l){ for(int j=1;j<i;j++){ res.push_back(p[j-1].ss); } for(int j=i+n-id;j<=n;j++){ res.push_back(p[j-1].ss); } return res; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...