제출 #1024938

#제출 시각아이디문제언어결과실행 시간메모리
1024938alex_2008Detecting Molecules (IOI16_molecules)C++14
100 / 100
45 ms8652 KiB
#include "molecules.h" #include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <set> #include <map> typedef long long ll; using namespace std; const int N = 2e5 + 10; const int INF = 1e9 + 10; vector <int> find_subset(int l, int u, vector <int> w) { int n = (int)w.size(); vector <pair<int, int>> esim; vector <ll> pref; for (int i = 0; i < n; i++) { esim.push_back({ w[i], i }); } sort(esim.begin(), esim.end()); ll s = 0; for (auto &it : esim) { s += it.first; pref.push_back(s); } for (int i = 0; i < n; i++) { ll w = 0; if (i) w = pref[i - 1]; int ind = lower_bound(pref.begin(), pref.end(), w + l) - pref.begin(); if (ind == n) continue; if ((pref[ind] - w) <= u) { vector <int> v; for (int j = i; j <= ind; j++) { v.push_back(esim[j].second); } return v; } } 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...