Submission #166404

# Submission time Handle Problem Language Result Execution time Memory
166404 2019-12-02T07:10:25 Z Sensei Hokej (COCI17_hokej) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

class Player {
public:
	int K, L;
	int no;
};

class Timeline {
public:
	int t;
	vector<int> players;
};

class Substitute {
public:
	int t;
	int no1, no2;
};

Timeline timelines[6];
Player init_players[6];
vector<Substitute> substitutions;

int main () {
	int N, M;

	cin >> M >> N;

	vector<Player> players(N);

	for (int i = 0; i < N; i++) {
		cin >> players[i].K >> players[i].L;
		players[i].no = i + 1;
	}

	sort(players.begin(), player.end(), [](Player a, Player b) {
		if (a.K == b.K) {
			return a.L > b.L;
		}

		return a.K > b.K;
	});

	long long ans = 0;

	for (int i = 0; i < N; i++) {
		int best_timeline = -1;
		int best_time_on_field = 0;

		for (int t = 0; t < 6; t++) {
			int time_on_field = min(players[i].L, max(0, (M - timelines[t].t) - players[i].L));

			if (time_on_field > best_time_on_field) {
				best_timeline = t;
				best_time_on_field = time_on_field;
			}
		}

		if (best_time_on_field > 0) {
			timelines[best_timeline].players.push_back(players[i].no);

			if (timelines[best_timeline].players.size() == 1) {
				init_players[best_timeline] = players[i];
			}
			else {
				Substitute substitution;
				substitution.t = timelines[best_timeline].t;
				substitution.no1 = timelines[best_timeline].players.back().no;
				substitution.no2 = players[i].no;

				substitutions.push_back(substitution);
			}

			timelines[best_timeline].t += best_time_on_field;
			ans += players[i].K * best_time_on_field;
		}
	}

	cout << ans << "\n";

	for (int t = 0; t < 6; t++) {
		printf("%d%c", " \n", init_players[t].no, [t + 1 == 6]);
	}

	cout << substitutions.size() << "\n";

	for (Substitute &substitution : substitutions) {
		printf("%d %d %d\n", substitution.t, substitution.no1, substitution.no2);
	}

	return 0;
}

Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:39:24: error: 'player' was not declared in this scope
  sort(players.begin(), player.end(), [](Player a, Player b) {
                        ^~~~~~
hokej.cpp:39:24: note: suggested alternative: 'players'
  sort(players.begin(), player.end(), [](Player a, Player b) {
                        ^~~~~~
                        players
hokej.cpp:71:64: error: request for member 'no' in 'timelines[best_timeline].Timeline::players.std::vector<int>::back()', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     substitution.no1 = timelines[best_timeline].players.back().no;
                                                                ^~
hokej.cpp:85:48: error: expected ',' before '+' token
   printf("%d%c", " \n", init_players[t].no, [t + 1 == 6]);
                                                ^
hokej.cpp:85:48: error: expected identifier before '+' token
hokej.cpp: In lambda function:
hokej.cpp:85:57: error: expected '{' before ')' token
   printf("%d%c", " \n", init_players[t].no, [t + 1 == 6]);
                                                         ^
hokej.cpp: In function 'int main()':
hokej.cpp:85:57: warning: format '%d' expects argument of type 'int', but argument 2 has type 'const char*' [-Wformat=]
hokej.cpp:85:57: warning: too many arguments for format [-Wformat-extra-args]