제출 #593565

#제출 시각아이디문제언어결과실행 시간메모리
593565Valaki2Detecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms296 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second const vector<int> e = {}; int n; vector<ll> v; vector<int> idx; ll a, b; vector<int> construct(int l, int r) { vector<int> result; for(int i = l; i <= r; i++) { result.pb(idx[i] - 1); } return result; } vector<int> solve() { idx.assign(1 + n + 1, 0); vector<pair<ll, int> > p(1 + n + 1, mp(0, 0)); for(int i = 1; i <= n; i++) { p[i].fi = v[i]; p[i].se = i; } sort(p.begin() + 1, p.end() - 1); for(int i = 1; i <= n; i++) { idx[i] = p[i].se; } ll sum = 0, len = -1; for(int i = 1; i <= n; i++) { sum += v[i]; if(sum >= a) { if(sum <= b) { return construct(1, i); } len = i - 1; break; } } if(len == -1) { return e; } sum = 0; int l = 1, r = len; for(int i = 1; i <= len; i++) { sum += v[i]; } while(r <= n) { if(sum >= a && sum <= b) { return construct(l, r); } sum -= v[l]; l++; r++; sum += v[r]; } return e; } vector<int> find_subset(int l, int u, vector<int> w) { n = w.size(); v.assign(1 + n + 1, 0); for(int i = 1; i <= n; i++) { v[i] = w[i - 1]; } a = l; b = u; return solve(); }
#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...