Submission #1069172

#TimeUsernameProblemLanguageResultExecution timeMemory
1069172kiethm07Detecting Molecules (IOI16_molecules)C++11
31 / 100
2 ms780 KiB
#include <bits/stdc++.h>

#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second

#define vi vector<int>
#define vii vector<pii>
#define pb(i) push_back(i)
#define all(x) x.begin(),x.end()

#define TEXT "a"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);

vector<int> find_subset(int l,int r,vector<int> w){
    int n = w.size();
    vector<pii> a(n);
    for (int i = 0; i < n; i++){
        a[i] = pii(w[i],i);
    }
    sort(all(a));
    vector<ll> pre(n), suf(n);
    pre[0] = 0;
    for (int i = 1; i < n; i++){
        pre[i] = pre[i - 1] + a[i].fi - a[0].fi;
    }
    suf[n - 1] = a[n - 1].fi - a[0].fi;
    for (int i = n - 2; i >= 0; i--){
        suf[i] = suf[i + 1] + a[i].fi - a[0].fi;
    }
    vector<int> res;
    for (ll x = 1; x <= n; x++){
        ll c = l - x * a[0].fi;
        ll d = r - x * a[0].fi;
        if (pre[x - 1] > d || suf[n - x] < c) continue;
        ll cur = 0;
        for (int j = n - 1; j >= 0; j--){
            int p = a[j].fi - a[0].fi;
            if (cur + p > d) continue;
            cur += p;
            res.push_back(a[j].se);
            if (res.size() == x) break;
        }
        break;
    }
    return res;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:52:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   52 |             if (res.size() == x) break;
      |                 ~~~~~~~~~~~^~~~
#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...