| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1273902 | almaz | Detecting Molecules (IOI16_molecules) | C++20 | 34 ms | 4128 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ar array
const int MOD = 1e9 + 7,INF = 1e9, N = 2e5 + 5;
vector<int> find_subset(int x, int y, vector<int> w) {
vector <pair<int,int>> b;
int n = w.size();
for(int i = 0;i < n;i++){
b.pb({w[i] , i});
}
sort(all(b));
vector <int> ans;
long long sum = b[0].ff;
int l = 0, r = 0;
while(l < n && r < n){
if(x <= sum && sum <= y){
int res = 0;
for(int i = l;i <= r;i++){
ans.pb(b[i].ss);
res += b[i].ff;
}
return ans;
}
else if(sum <= x && r < n){
r++;
sum += b[r].ff;
}
else if(sum >= y && l < r){
sum -= b[l].ff;
l++;
}
else{
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... | ||||
