Submission #767745

#TimeUsernameProblemLanguageResultExecution timeMemory
767745drdilyorAkcija (COCI21_akcija)C++17
0 / 110
181 ms8656 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { cin.tie(0)->sync_with_stdio(0); int n, k; cin >> n >> k; vector<pair<int,int>> arr(n); for (auto&[cost, d] : arr) cin >> cost >> d; assert(n <= 20); vector<pair<int,ll>> ans; for (int mask = 0; mask < (1<< n); mask++) { vector<int> d; ll cost = 0; for (int i = 0; i < n; i++) if (mask&(1 << i)) { d.push_back(arr[i].second); cost += arr[i].first; } sort(d.begin(), d.end()); bool ok = true; for (int i = 0; i < (int)d.size(); i++) { if (d[i] <= i)ok = false; } if (ok) ans.emplace_back(__builtin_popcount(mask), cost); } sort(ans.begin(), ans.end(), greater<>()); for (int i = 0; i < k; i++) cout << ans[i].first << ' ' << ans[i].second << '\n'; return 0; }
#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...