제출 #416901

#제출 시각아이디문제언어결과실행 시간메모리
416901KalasLavasDetecting Molecules (IOI16_molecules)C++14
69 / 100
51 ms5404 KiB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//#undef LOCALKL
#define IO \
ios_base::sync_with_stdio(0);(cin).tie(0);(cout).tie(0)
#define y1 y1_
#define prev prev_
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#ifdef LOCALKL
#define cerr cerr<<"\33[1;32m"
#define cout cout<<"\33[0m"
#else
#define endl '\n'
#define cerr if(1){}else cerr
#endif
#define OK cout<<"OK\n"<<endl;
#define setpre(k) fixed<<setprecision(k)
#define mmset(k,y) memset(k,y,sizeof(k))
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ull = unsigned long long;
using intt = long long;
using ll = long long;
using ld = long double;

const ll m9 = 998244353;
const ll m7 = 1000000007;
const ll m18 = 1000000000000000000;
const ll i127 = 2139062143;
const ll l127 = 9187201950435737471;
int n, x, pr[200001];
pii a[200001];

vector<int> find_subset(int l, int u, vector<int> w) {
    n = w.size();
    for(int i=0;i<n;i++) a[i] = {w[i], i};
    sort(a, a+n);
    
    x = a[0].F;
    for(int i=0;i<n;i++) a[i] = {a[i].F-x, a[i].S};
    for(int i=1;i<=n;i++) pr[i] = pr[i-1] + a[n-i].F;
    
    // for(int i=1;i<=n;i++) cerr<<pr[i]<<',';cerr<<endl;
    
    for(int j=1;j<=n;j++)
    {
        if(x*j+pr[j] < l or u < x*j) continue;
        // cerr<<j*x<<' '<<j*x+pr[j]<<endl;
        for(int i=j;i<=n;i++) 
            if(l <= x*j+pr[i]-pr[i-j] and x*j+pr[i]-pr[i-j] <= u)
            {
                vector<int>res;
                for(int k=n-i; k<n-i+j; k++) res.emplace_back(a[k].S);
                return res;
            }
    }
    return vector<int>(0);
}
#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...