Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 16/16 3,988 MiB 0,231 s OK
#2 [več] 16/16 4,102 MiB 0,079 s OK
#3 [več] 17/17 3,227 MiB 0,091 s OK
#4 [več] 17/17 4,203 MiB 0,207 s OK
#5 [več] 17/17 4,195 MiB 0,207 s OK
#6 [več] 17/17 4,191 MiB 0,244 s OK

Ocenjevani program (pica.cpp):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

int main( int argc, char * argv[] ) 
{
    long long k, n;
    cin >> n >> k;
    string line;
    getline( cin, line );

    vector<long long> all_max;
    for( long long i = 0; i < n; i++ )
    {
        long long max = 0, num;
        getline( cin, line );
        stringstream ss(line );

        while( !ss.eof() )
        {
            ss >> num;
            if( num > max ) max = num;
        }
        all_max.push_back( max );
    }

    sort( all_max.begin(), all_max.end() );
    long long val = 0;
    for( long long i = 0; i < k; i++ )
    {
        val += all_max[i];
    }
    std::cout << val << std::endl;



    return 0;
}