제출 #925815

#제출 시각아이디문제언어결과실행 시간메모리
925815Art_ogoDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "molecules.h" #define ve vector #define ll long long #define fi first #define se second using namespace std; vector<int> find_subset(int L, int u, vector<int> w) { int n = w.size(); ve<pair<int, int> > v(n); for(int i = 0; i < n; i++) v[i] = {w[i], i + 1}; sort(v.begin(), v.end()); ve<ll> p(n + 1, 0); for(int i = 1; i <= n; i++) p[i] = p[i - 1] + v[i - 1].fi; int l= 0, r = 0; while(l <= n && r <= n){ ll sum = p[r] - p[l]; if(sum >= L && sum <= u){ ve<int> res; ll csum = 0; for(int i = l + 1; i <= r; i++){ res.push_back(v[i].se); csum += v[i].fi; } assert(csum == sum); return res; } else if(sum < L) r++; else l++; } return {}; }
#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...