제출 #1343113

#제출 시각아이디문제언어결과실행 시간메모리
1343113curious_tigerDetecting Molecules (IOI16_molecules)C++20
100 / 100
34 ms4124 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long

vector<int> find_subset(int l, int u, vector<int> weight) {
    vector<pair<int, int>> w (0);
    for (int i=0; i<weight.size(); i++) {
        w.emplace_back(weight[i], i);
    }
    sort(w.begin(), w.end());
    int i=0, j=0, n=w.size();
    ll s=w[0].first;
    bool flag = false;
    while (i<=j && j<n) {
        if (s<l) {
            if (j>=n-1)
                break;
            j++;
            s += w[j].first;
        }
        else if (u<s) {
            if (i>=n-1)
                break;
            s -= w[i].first;
            i++;
        }
        else {
            flag = true;
            break;
        }
    }
    vector<int> subset (0);
    if (!flag)
        return subset;
    while (i<=j) {
        subset.push_back(w[i].second);
        i++;
    }
    return subset;
}
#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...