제출 #416935

#제출 시각아이디문제언어결과실행 시간메모리
416935CollypsoDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define vt vector #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() #pragma GCC optimize ("O3") #pragma GCC optimize ("O2") #define F first #define S second //#define endl '\n' //#define int long long using namespace std; vt<int> find_subset(int l, int u, vt<int> ww) { vt<pii> w(sz(ww)); for(int i = 0; i < sz(ww); i++) w[i] = {ww[i], i}; sort(all(w)); ll sum = 0; vt<pii> elements; for(int i = 0; i < sz(w) && sum + w[i].F <= l; i++) sum += w[i].F, elements.pb(w[i]); for(int i = sz(w) - 1, j = sz(elements) - 1; i >= 0 && j >= 0 && sum < l; i--, j--) { sum -= elements[j].F, sum += w[i].F; elements[j] = w[i]; } if (sz(elements) == 0 && w[0].F > l && w[0].F < u) return {w[0].S}; if (sum < l) return {}; vt<int> ans; for(int i = 0; i < sz(elements); i++) ans.pb(elements[i].S); return ans; }
#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...