제출 #757771

#제출 시각아이디문제언어결과실행 시간메모리
757771taherDetecting Molecules (IOI16_molecules)C++17
100 / 100
61 ms5540 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "C:\GCC\debug.h" #else #define debug(...) void(42) #endif vector<int> find_subset(int l, int u, vector<int> w) { int n = (int) w.size(); cin >> n >> l >> u; vector<pair<int, int>> a(n); for (int i = 0 ; i < n ; i++) { a[i].first = w[i]; a[i].second = i; } sort(a.begin(), a.end()); auto Exit = [&](int left, int right, int m) { vector<int> res; for (int i = left; i < right; i++) { res.push_back(a[i].second); } return res; }; int left = 0; long long sum = 0; for (int i = 0; i < n; i++) { sum += 1ll * a[i].first; while (sum > u) { sum -= a[left++].first; } if (sum >= l && sum <= u) { return Exit(left, i + 1, i + 1 - left); } } if (sum >= l && sum <= u) { return Exit(left, n, n - left); } vector<int> empt; return empt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...