제출 #114844

#제출 시각아이디문제언어결과실행 시간메모리
114844oolimryDetecting Molecules (IOI16_molecules)C++14
100 / 100
83 ms7660 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<int> v;

    int n = w.size();
    typedef pair<long long, long long> ii;

    ii arr[n];

    for(int i = 0;i < n;i++){
        arr[i] = ii(w[i],i);
    }

    sort(arr,arr+n);

    long long low = 0;
    long long high = 0;
    vector<int> ll;
    vector<int> hh;
    for(int c = 0;c < n;c++){
        low += arr[c].first;
        high += arr[n-c-1].first;
        ll.push_back(arr[c].second);
        hh.push_back(arr[n-c-1].second);
        if(l <= low && low <= u){
            return ll;
        }
        else if(l <= high && high <= u){
            return hh;
        }
        else if(low < l && high > u){
            for(int i = 0;i <= c;i++){
                long long x = ll[i];
                long long y = hh[i];
                low -= w[x];
                low += w[y];
                hh[i] = x;
                ll[i] = y;
                if(l <= low && low <= u){
                    return ll;
                }
            }
            while(true){

            }
        }
    }


    return v;
}


#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...