| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1288808 | muhammad-ahmad | Detecting Molecules (IOI16_molecules) | C++20 | 39 ms | 8348 KiB |
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define ll long long
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int, int>> X;
for (int i = 0; i < n; i++){
X.push_back({w[i], i});
}
sort(X.begin(), X.end());
int a[n + 1], idx[n + 1];
for (int i = 0; i < n; i++){
a[i + 1] = X[i].first;
idx[i + 1] = X[i].second;
}
ll pref[n + 2] = {}, suf[n + 2] = {};
for (int i = 1; i <= n; i++){
pref[i] = pref[i - 1];
pref[i] += a[i];
}
for (int i = n; i >= 1; i--){
suf[i] = suf[i + 1];
suf[i] += a[i];
}
suf[0] = u;
suf[0] *= 2;
int R = 0;
for (int L = 0; L <= n; L++){
while (R <= n && (ll)(pref[L] + suf[R]) > u) {
R++;
}
// cout << L << ' ' << R << endl;
ll s = pref[L] + suf[R];
if (s >= l && s <= u && R > L){
vector<int> ans;
for (int i = 1; i <= L; i++) ans.push_back(idx[i]);
for (int i = R; i <= n; i++) ans.push_back(idx[i]);
return ans;
}
}
return {};
}
컴파일 시 표준 에러 (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... | ||||
