제출 #1024885

#제출 시각아이디문제언어결과실행 시간메모리
1024885slivajanDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms600 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long un;
typedef vector<un> vuc;


#define REP(i, a, b) for(un i = a; i < b; i++)
#define FEAC(i, a) for (auto&& i : a)
#define vec vector
#define ALL(x) (x).begin(), (x).end()

std::vector<int> find_subset(int l, int u, std::vector<int> w) {

    vec<pair<un, un>> toSort((un)w.size());

    REP(i, 0, (un)w.size()) toSort[i] = {w[i], i};

    sort(ALL(toSort));

    vuc tab(w.size());

    REP(i, 0,(un) w.size()){
        w[i] = toSort[i].first;
        tab[i] = toSort[i].second;
    }

    un ls = 0;
    un rs = 0;

    un ptr = 0;

    while((ls < l) and (rs < l)){
        ls += w[ptr];
        rs += w[w.size() - ptr - 1];

        ptr++;
    }

    if (ls > u){
        return {};
    }

    vec<int> ret(ptr);
    iota(ALL(ret), 0);

    un newptr = 0;
    while(ls < l){
        ret[newptr] = ((un)w.size()) - 1 - newptr;
        ls += (w[ret[newptr]] - w[newptr]);
        newptr++;
    }

    REP(i, 0, (un)ret.size()){
        ret[i] = tab[ret[i]];
    }

    return ret;
}
#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...