| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1247084 | julia_08 | Detecting Molecules (IOI16_molecules) | C++20 | 36 ms | 4140 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 5e5 + 10;
int dp[MAXN];
vector<int> solve(int l, int u, vector<pair<int, int>> &W){
ll sum = 0;
vector<int> ans;
for(int i=0; i<W.size(); i++){
sum += W[i].first;
if(l <= sum && sum <= u){
for(int j=0; j<=i; j++) ans.push_back(W[j].second);
return ans;
}
if(sum > u){
if(l <= sum - W[0].first && sum - W[0].first <= u){
for(int j=1; j<=i; j++) ans.push_back(W[j].second);
return ans;
}
}
}
return {};
}
vector<int> find_subset(int l, int u, vector<int> w){
if(l > u) return {};
vector<pair<int, int>> W;
for(int i=0; i<w.size(); i++) W.push_back({w[i], i});
sort(W.begin(), W.end());
if(W[0].first > u) return {};
for(auto x : W){
if(l <= x.first && x.first <= u){
return {x.second};
}
}
if(W[0].first <= u - l) return solve(l, u, W);
vector<int> ans;
int r = -1;
ll sum = 0;
for(int i=0; i<W.size(); i++){
while(r + 1 < W.size() && sum < l){
r ++;
sum += W[r].first;
}
if(sum < l) break;
if(sum <= u){
for(int j=i; j<=r; j++) ans.push_back(W[j].second);
return ans;
}
sum -= W[i].first;
}
return {};
}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... | ||||
