Submission #617425

#TimeUsernameProblemLanguageResultExecution timeMemory
617425Dremix10Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms256 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #ifdef dremix #define p(x) cerr<<#x<<" = "<<x<<endl; #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl; #define pp(x) cerr<<#x<<" = ("<<x.F<<" - "<<x.S<<")"<<endl; #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl; #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl; #else #define p(x) {} #define p2(x,y) {} #define pp(x) {} #define pv(x) {} #define ppv(x) {} #endif #define endl '\n' #define all(x) (x).begin(),(x).end() #define F first #define S second const int N = 5e5+5; const int MOD = 1e9+7; const ll INF = 1e18+5; bool cmp(pi a, pi b){ return a.F > b.F; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<pi> arr(n); int i; for(i=0;i<n;i++){ arr[i] = {w[i],i}; } sort(all(arr),cmp); vector<pi> ans; ll sum = 0; for(i=0;i<n;i++){ sum += arr[i].F; ans.push_back(arr[i]); if(sum >= l)break; } int j = n-1; int k = 0; while(j > i && k <= i && sum > u){ sum -= arr[k].F; sum += arr[j].F; ans[k] = arr[j]; k++; j--; } if(sum > u) return {}; vector<int> res; for(auto x : ans) res.push_back(x.S); 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...