Submission #535436

#TimeUsernameProblemLanguageResultExecution timeMemory
535436mario05092929Detecting Molecules (IOI16_molecules)C++14
100 / 100
71 ms7152 KiB
#include "molecules.h" #include <bits/stdc++.h> #define x first #define y second using namespace std; typedef long long ll; typedef pair <ll,ll> pi; typedef vector <int> vec; int n; pi a[200005]; ll L,R; vec find_subset(int l,int r,vec w) { L = l, R = r; n = w.size(); for(int i = 0;i < n;i++) a[i].x = w[i], a[i].y = i; queue <int> q; ll sum = 0; int i; sort(a,a+n); if(a[0].x > R) return {}; for(i = 0;i < n;i++) { if(L <= sum+a[i].x&&sum+a[i].x <= R) { vector <int> ans; for(int j = 0;j <= i;j++) ans.push_back(a[j].y); return ans; } if(sum+a[i].x < L) { sum += a[i].x; q.push(i); } else break; } for(int j = i;j < n;j++) { int x = q.front(); q.pop(); sum -= a[x].x; sum += a[j].x; q.push(j); if(L <= sum&&sum <= R) { vector <int> ans; while(!q.empty()) { ans.push_back(a[q.front()].y); q.pop(); } return ans; } if(sum > R) while(1); } return {}; }
#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...