From 1f9cdd4cce664439625f13da1baf894190b7e9a6 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 17 Feb 2020 20:29:47 +0700 Subject: Thank you Corona for giving me some time to do this --- codechef/theatre.cc | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 codechef/theatre.cc (limited to 'codechef/theatre.cc') diff --git a/codechef/theatre.cc b/codechef/theatre.cc new file mode 100644 index 0000000..ea576f8 --- /dev/null +++ b/codechef/theatre.cc @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + +using namespace std; + +int +main() +{ + int k, total_profit {0}; + string movies {"ABCD"}; + vector showtimes {3, 6, 9, 12}; + vector prices {25, 50, 75, 100}; + + cin >> k; + while (k--) + { + map> requests; + int n, t, profit {-400}; + char m; + + cin >> n; + while (n--) + { + cin >> m >> t; + requests[m][t]++; + } + + for (int i = 0; i < 24; ++i) + { + for (int j = 0; j < 24; ++j) + { + vector tickets {requests[movies[0]][showtimes[0]], + requests[movies[1]][showtimes[1]], + requests[movies[2]][showtimes[2]], + requests[movies[3]][showtimes[3]]}; + int p {0}; + + sort (tickets.begin(), tickets.end()); + for (int l = 0; l < 4; ++l) + p += tickets[l] ? tickets[l]*prices[l] : -100; + profit = max (p, profit); + next_permutation (showtimes.begin(), showtimes.end()); + } + next_permutation (movies.begin(), movies.end()); + } + + cout << profit << endl; + total_profit += profit; + } + cout << total_profit << endl; +} -- cgit 1.4.1