Rezultati

Up. imeNalogaJezikRezultatČas oddaje
pokosimo-2019 Kuponi za pice C++ 100/100OK 24. apr '19 @ 16:31

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 16/16 3,480 MiB 0,067 s OK
#2 [več] 16/16 3,191 MiB 0,031 s OK
#3 [več] 17/17 3,379 MiB 0,061 s OK
#4 [več] 17/17 3,570 MiB 0,055 s OK
#5 [več] 17/17 3,469 MiB 0,073 s OK
#6 [več] 17/17 3,480 MiB 0,049 s OK

Ocenjevani program (pice.cpp):
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n, k;
	scanf("%d %d ", &n, &k);
	//cin >> n >> k;
	vector<int> pice;
	for(int i=0; i<n; ++i) {
		int a, mak = 0;
		char c;
		scanf("%d%c", &a, &c);
		while(c == ' ') {
			mak = max(a, mak);
			//cout << a << ' ';
			scanf("%d%c", &a, &c);
		}
		mak = max(a, mak);
		//cout << a;
		//cout << endl;
		pice.push_back(mak);
	}
	sort(pice.begin(), pice.end());
	long long out = 0;
	for(int i=0; i<k; ++i) {
		out += (long long) pice[i];
	}
	cout << out << endl;
	return 0;
}