CSES - Datatähti 2017 alku - Results
Submission details
Task:Kolikot
Sender:Shrike
Submission time:2016-10-10 19:30:31 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:34:6: error: '::main' must return 'int'
 main()
      ^

Code

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
# include <sstream>

using namespace std;
typedef long long ll;

ll
atoi (string c)
{
	stringstream s;
	ll i;
	s << c;
	s >> i;
	return i;
}

vector<ll>
llo_vec (string str, ll size)
{
	vector<ll> vec(size);
	istringstream ssin(str);
        ll input, j = 0;
        while(ssin >> input) {
            vec[j] = input;
	    j++;
        }
	return vec;
}

ll
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string buf;
	ll n;

	getline (cin, buf);
	n = atoi (buf);
	getline (cin, buf);
	vector<ll> vec = llo_vec(buf, n);

	sort (vec.begin(), vec.end());
	ll i, cand;
	cand = 1;
	for (i = 0; i < n; i++) {
		if (vec[i] > cand)
			break;
		else
			cand += vec[i];
	}
	cout << cand << "\n";
	return 0;
}