# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647154 | 2022-10-01T16:59:51 Z | Alma | Akcija (COCI21_akcija) | C++14 | 751 ms | 524288 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second using ll = long long; using ii = pair<int,int>; const int INF = 1e9; const ll LLINF = 1e18; using vi = vector<int>; using vvi = vector<vi>; void setIO (string fileName) { ios::sync_with_stdio(false); cin.tie(NULL); if (fileName != "std") { freopen((fileName + ".in").c_str(), "r", stdin); freopen((fileName + ".out").c_str(), "w", stdout); } } int n, k; vector<ii> ans, gifts; // bool comp(ii& a, ii& b) { // if (a.fi == b.fi) return a.se < b.se; // return a.fi > b.fi; // } void bt (int i, int cnt, int val) { if (i == n) { // cerr << cnt << ' ' << val << '\n'; ans.push_back({-cnt, val}); return; } // cerr << i << ' ' << cnt << '\n'; bt(i+1, cnt, val); if (gifts[i].fi <= cnt) return; bt(i+1, cnt+1, val+gifts[i].se); } int main() { setIO("std"); cin >> n >> k; gifts = vector<ii>(n); for (ii& par: gifts) cin >> par.se >> par.fi; sort(gifts.begin(), gifts.end()); bt(0, 0, 0); sort(ans.begin(), ans.end()); for (int i = 0; k > 0 and i < (int)ans.size(); i++, k--) { cout << -ans[i].fi << ' ' << ans[i].se << '\n'; } while (k > 0) { cout << "0 0\n"; k--; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 751 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 751 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 729 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 4560 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 742 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 751 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |