| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1325805 | antarbanik | Detecting Molecules (IOI16_molecules) | C++20 | 41 ms | 6784 KiB |
#include<bits/stdc++.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>> vp(n);
for(int i = 0;i<n;++i){
vp.push_back({w[i], i});
}
sort(vp.rbegin(),vp.rend());
vector<ll> pref(n);
pref[0] = vp[0].first;
for(int i = 1; i<n;++i) pref[i] = pref[i-1] + vp[i].first;
bool f = 0;
vector<int> ans;
// for(auto e : pref) cout<<e<<" ";
// cout<<endl;
for(int i = 1;i<n;++i){
int low = 0, high = i;
int temp = -1;
while(low <= high){
int m = low + (high - low) / 2;
ll s = pref[i] - pref[m];
if(pref[i] >= l && pref[i] <= u){
temp = 0;
break;
}
if(s >= l && s <= u){
temp = m + 1;
break;
}
if(s > u){
low = m + 1;
}
else high = m - 1;
}
if(temp != -1){
// cout<<i<<" "<<temp;
// cout<<endl<<endl;
for(int j = temp; j<=i; ++j){
// cout<<j<<" ";
ans.push_back(vp[j].second);
f = 1;
}
break;
}
// cout<<i<<" "<<temp<<endl;
}
// cout<<vp[0].second<<" "<<vp[1].second;
// cout<<endl;
if(f){
sort(ans.begin(),ans.end());
return ans;
}
vector<int> ans2;
bool f2 = 0;
for(int i = 0;i<n;++i){
if(w[i] >= l && w[i] <= u){
ans2.push_back(i);
f2 = 1;
break;
}
}
if(f2) return ans2;
return {};
}
// int main(){
// vector<int> v = find_subset(15, 17, {1, 1, 100, 10, 3});
// // vector<int> v = find_subset(15, 17, {15});
// for(auto e : v) cout<<e<<" ";
// }컴파일 시 표준 에러 (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... | ||||
