Submission #1065075

#TimeUsernameProblemLanguageResultExecution timeMemory
1065075MrPavlitoDetecting Molecules (IOI16_molecules)C++17
100 / 100
34 ms5480 KiB
#include "molecules.h" #include <bits/stdc++.h> //#define int long long #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second //#define endl "\n" #define pii pair<int,int> using namespace std; const int MAXN = 1e5+5; const int mod7 = 1e9+7; const long long inf = 1e18; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<pii> niz(n); for(int i=0; i<n; i++)niz[i] = mp(w[i],i); sort(all(niz)); int pl = 0; int pr = 0; long long trsum = niz[0].fi; vector<int> resenje; while(pr< n) { if(trsum <= u && trsum>=l) { for(int i=pl; i<=pr; i++)resenje.pb(niz[i].sc); return resenje; } else if(trsum > u) { while(pl < pr && trsum > u) { trsum-= niz[pl++].fi; if(trsum <= u && trsum>=l) { for(int i=pl; i<=pr; i++)resenje.pb(niz[i].sc); return resenje; } } pr++; if(pr != n)trsum+= niz[pr].fi; } else { pr++; if(pr != n)trsum+= niz[pr].fi; } } return resenje; }
#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...