Submission #1068809

#TimeUsernameProblemLanguageResultExecution timeMemory
1068809kiethm07Detecting Molecules (IOI16_molecules)C++11
9 / 100
1 ms600 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define vii vector<pii> #define pb(i) push_back(i) #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); vector<int> find_subset(int l,int r,vector<int> w){ int n = w.size(); vector<pii> a(n); for (int i = 0; i < n; i++){ a[i] = pii(w[i],i); } sort(all(a)); vector<ll> suf(n,0); suf[n - 1] = a[n - 1].fi - a[0].fi; for (int i = n - 2; i >= 0; i--){ suf[i] = suf[i + 1] + a[i].fi - a[0].fi; } vector<int> res; for (ll x = 1; x <= n; x++){ ll c = l - x * a[0].fi; ll d = r - x * a[0].fi; if (d < 0) break; if (suf[n - x] < c) continue; //cout << x << " " << c << " " << d << " " << sum << "\n"; for (int j = n - 1; j > n - 1 - x; j--){ res.push_back(a[j].se); } break; } return res; } // //int main(){ // int l = 15,r = 17; // vector<int> w = {6,8,8,7}; // vi v = find_subset(l,r,w); // for (int i : v) cout << i << " "; cout << "\n"; // l = 14, r = 15; // w = {5,5,6,6}; // v = find_subset(l,r,w); // for (int i : v) cout << i << " "; cout << "\n"; // l = 10, r = 20; // w = {15,17,16,18}; // v = find_subset(l,r,w); // for (int i : v) cout << i << " "; cout << "\n"; // return 0; //}
#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...