Submission #647154

#TimeUsernameProblemLanguageResultExecution timeMemory
647154AlmaAkcija (COCI21_akcija)C++14
0 / 110
751 ms524288 KiB
#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 (stderr)

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen((fileName + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen((fileName + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...