Submission #879458

#TimeUsernameProblemLanguageResultExecution timeMemory
879458TAhmed33Akcija (COCI21_akcija)C++98
10 / 110
485 ms524288 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 25; typedef long long ll; vector <pair <ll, ll>> subs; int n; pair <ll, ll> a[MAXN]; void recurse (int pos, int sze, ll cost) { if (pos > n) { subs.push_back({sze, cost}); return; } recurse(pos + 1, sze, cost); if (sze + 1 <= a[pos].second) recurse(pos + 1, sze + 1, cost + a[pos].first); } int main () { cin >> n; int k; cin >> k; for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; sort(a + 1, a + n + 1, [] (pair <ll, ll> &x, pair <ll, ll> &y) { return x.second < y.second; }); recurse(1, 0, 0); sort(subs.begin(), subs.end(), [] (pair <ll, ll> &a, pair <ll, ll> &b) { return a.first == b.first ? a.second < b.second : a.first > b.first; }); for (int i = 0; i < k; i++) { cout << subs[i].first << " " << subs[i].second << '\n'; } }
#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...