Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 16/16 3,480 MiB 0,097 s OK
#2 [več] 16/16 5,070 MiB 0,061 s OK
#3 [več] 17/17 3,164 MiB 0,073 s OK
#4 [več] 17/17 3,695 MiB 0,116 s OK
#5 [več] 17/17 3,699 MiB 0,104 s OK
#6 [več] 17/17 3,699 MiB 0,097 s OK

Ocenjevani program (main.cpp):
#include <bits/stdc++.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;

int N, K;
vector<int> v;

int _x;

vector<int> f(string x)
{
    int mx = 0;
    vector<int> _v;

    for (int i = 0; i < x.size(); i++) {
        int j, u = 0;
        for (j = i; j < x.size() && '0' <= x[j] && x[j] <= '9'; j++) u *= 10, u += x[j] - '0';
        _v.push_back(u);
        i = j; 
        mx = max(mx, u);    
    }

    if (_x++ > 1) v.push_back(mx);

    return _v;
}

int main()
{
    string in; getline(cin, in);

    N = f(in)[0]; K = f(in)[1];
    for (int i = 0; i < N; i++) {
        string line; getline(cin, line);
        f(line);
    }

    sort(v.begin(), v.end());

    ll ans = 0;
    for (int i = 0; i < K; i++) ans += 1LL * v[i];

    cout << ans << endl;

    return 0;
}