Submission #1065068

#TimeUsernameProblemLanguageResultExecution timeMemory
1065068MrPavlitoDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms604 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 = 0; vector<int> resenje; while(pr< n) { trsum+= niz[pr].fi; if(trsum <= u && trsum>=l) { for(int i=pl; i<=pr; i++)resenje.pb(niz[i].sc); return resenje; } if(trsum >= u) { trsum-=niz[pl++].fi; if(pl > pr) { pr++; if(pr >= n)break; trsum+=niz[pr].fi; } if(trsum <= u && trsum>=l) { for(int i=pl; i<=pr; i++)resenje.pb(niz[i].sc); return resenje; } } else pr++; } 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...