# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
746305 | Sami_Massah | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 12, mod = 998244353, inf = 1e9 + 12 ;
long long mn[maxn], mx[maxn];
vector <int> ans, f;
vector <pair<int, int>> a2;
vector <int> find_subset(int l, int r, vector <int> a){
int n = a.size();
for(int i = 0; i < n; i++)
a2.push_back(make_pair(a[i], i));
sort(a2.begin(), a2.end());
mn[0] = a2[0].first;
for(int i = 1; i < n; i++)
mn[i] = mn[i - 1] + a2[i].first;
mx[n - 1] = a[n - 1];
for(int i = n - 2; i >= 0; i--)
mx[i] = mx[i + 1] + a2[i].first;
for(int i = 1; i <= n; i++){
if(mn[i - 1] <= r && l <= mx[n - i]){
long long sum = mx[n - i];
for(int j = n - i; j < n; j++)
ans.push_back(j);
int loc = 0;
while(sum < l || sum > r){
if(ans[loc] == loc){
loc += 1;
}
else{
int now = ans[loc];
sum = sum - a2[now].first + a2[now - 1].first;
ans[loc] -= 1;
}
}
for(int j = 0; j < ans.size(); j++){
//cout << ans[j] << endl;
ans[j] = a2[ans[j]].second;
}
// cout << endl;
return ans;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |