Submission #417920

#TimeUsernameProblemLanguageResultExecution timeMemory
417920OdaveyDetecting Molecules (IOI16_molecules)C++14
100 / 100
54 ms7116 KiB
// // ~oisín~ C++ Template // #include <bits/stdc++.h> #define MX_N 5001 #define mp make_pair #define mod7 1000000007 #define modpi 314159 #define PI 3.141592653589793238 #define pb push_back #define FastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define All(a) a.begin(),a.end() #define fi first #define se second #define ll long long int #define ull unsigned long long int int kx[8] = {+2, +2, -2, -2, +1, +1, -1, -1}; int ky[8] = {+1, -1, +1, -1, +2, -2, +2, -2}; int d9x[9] = {+1, +1, +1, +0, +0, +0, -1, -1, -1}; int d9y[9] = {+1, +0, -1, +1, +0, -1, +1, +0, -1}; int dx4[4] = {+0, +0, +1, -1}; int dy4[4] = {+1, -1, +0, +0}; ll gcd(ull a, ull b){ return (a==0)?b:gcd(b%a,a); } ll lcm(ull a, ull b){ return a*(b/gcd(a,b)); } const long long INF = 1e18; using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); pair<ll, int> a[n]; for(int i=0;i<n;++i){ a[i] = {w[i], i}; } sort(a, a+n); ll _l = l; ll _u = u; int L = 0; int R = 0; ll run = a[0].fi; vector<int> ans; while(L <= R){ if(run < _l){ ++R; if(R == n){ return ans; } run += a[R].fi; }else if(run > _u){ run -= a[L].fi; ++L; }else{ for(int i=L;i<=R;++i){ ans.pb(a[i].se); } return ans; } } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
   68 | }
      | ^
#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...