| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1205483 | trimkus | Detecting Molecules (IOI16_molecules) | C++20 | 36 ms | 4132 KiB |
#include <bits/stdc++.h>
using namespace std;
// #define LOCAL
#ifndef LOCAL
#include "molecules.h"
#endif
using ll = long long;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int N = (int)w.size();
vector<array<int, 2>> a;
for (int i = 0; i < N; ++i) {
a.push_back({w[i], i});
}
sort(begin(a), end(a));
int left = 0;
ll sum = 0;
vector<int> res;
for (int i = 0; i < N; ++i) {
sum += a[i][0];
while (sum > u) {
sum -= a[left][0];
left++;
}
if (sum >= l && sum <= u) {
for (int j = left; j <= i; ++j) {
res.push_back(a[j][1]);
}
sort(begin(res), end(res));
return res;
}
}
return {};
}
#ifdef LOCAL
/*
4 15 17
6 8 8 7
4 14 15
5 5 6 6
4 10 20
15 17 16 18
*/
#include <cstdio>
#include <vector>
#include <cassert>
int main() {
int n, l, u;
assert(3 == scanf("%d %d %d", &n, &l, &u));
std::vector<int> w(n);
for (int i = 0; i < n; i++)
assert(1 == scanf("%d", &w[i]));
std::vector<int> result = find_subset(l, u, w);
printf("%d\n", (int)result.size());
for (int i = 0; i < (int)result.size(); i++)
printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
}
#endif
컴파일 시 표준 에러 (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... | ||||
