Submission #471271

# Submission time Handle Problem Language Result Execution time Memory
471271 2021-09-08T04:39:22 Z almothana05 Kisik (COCI19_kisik) C++14
90 / 90
365 ms 43920 KB
// #include<bits\stdc++.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<cassert>
#include<vector>
using namespace std;
vector<pair<long long , long long > >num , pref;
priority_queue<long long>q;
int main(){
	 ios_base::sync_with_stdio(false);
	  cin.tie(NULL);
    // freopen("herding.in", "r", stdin);
    // freopen("herding.out", "w", stdout);
	long long menge ,numm , nummer , t , gew , rechner = 0 , erg = 0;
	cin >> menge >> gew;
	for(int i = 0 ; i < menge;  i++){
		cin >> numm >> nummer;
		num.push_back(make_pair(nummer , numm));
	}
	sort(num.begin() , num.end());

	for(int i = 0 ; i < gew ; i++){
		q.push(num[i].second);
		rechner += num[i].second;
	}
	erg = rechner * num[gew - 1].first;
	for(int i = gew ; i < menge ; i++){
		rechner -= q.top();
		q.pop();
		rechner += num[i].second;
		q.push(num[i].second);
		erg = min(erg , rechner * num[i].first);
	}
	cout << erg;
	return 0;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:18:35: warning: unused variable 't' [-Wunused-variable]
   18 |  long long menge ,numm , nummer , t , gew , rechner = 0 , erg = 0;
      |                                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 12392 KB Output is correct
2 Correct 274 ms 24936 KB Output is correct
3 Correct 223 ms 30680 KB Output is correct
4 Correct 201 ms 28824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 15764 KB Output is correct
2 Correct 27 ms 4216 KB Output is correct
3 Correct 54 ms 7984 KB Output is correct
4 Correct 170 ms 22184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 10988 KB Output is correct
2 Correct 211 ms 24100 KB Output is correct
3 Correct 155 ms 12892 KB Output is correct
4 Correct 352 ms 43920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12760 KB Output is correct
2 Correct 365 ms 34096 KB Output is correct
3 Correct 105 ms 12320 KB Output is correct
4 Correct 245 ms 33348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 24032 KB Output is correct
2 Correct 236 ms 25800 KB Output is correct
3 Correct 190 ms 20768 KB Output is correct
4 Correct 112 ms 16036 KB Output is correct