Submission #313923

#TimeUsernameProblemLanguageResultExecution timeMemory
313923phathnvKisik (COCI19_kisik)C++11
90 / 90
342 ms25068 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "KISIK" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 1e6 + 1; const ll INF = 1e18; int n, k; ii a[N]; void readInput(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++) cin >> a[i].Y >> a[i].X; } void solve(){ sort(a + 1, a + 1 + n); ll sumW = 0, res = INF; priority_queue <int> pq; for(int i = 1; i <= n; i++){ pq.push(a[i].Y); sumW += a[i].Y; if (i >= k){ res = min(res, sumW * a[i].X); sumW -= pq.top(); pq.pop(); } } cout << res; } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }

Compilation message (stderr)

kisik.cpp: In function 'int main()':
kisik.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   45 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kisik.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   46 |         freopen(taskname".out", "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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...