diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-17 20:29:47 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-17 20:29:47 +0700 |
commit | 1f9cdd4cce664439625f13da1baf894190b7e9a6 (patch) | |
tree | 2d1af656692ece87c83c4f57196b5f3825d475b7 /codechef/theatre.cc | |
parent | 82e6cf7d1046d6cee16f7e8b044ec33e7ec6c4b7 (diff) | |
download | cp-1f9cdd4cce664439625f13da1baf894190b7e9a6.tar.gz |
Thank you Corona for giving me some time to do this
Diffstat (limited to 'codechef/theatre.cc')
-rw-r--r-- | codechef/theatre.cc | 54 |
1 files changed, 54 insertions, 0 deletions
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 <algorithm> +#include <iostream> +#include <map> +#include <string> +#include <vector> + +using namespace std; + +int +main() +{ + int k, total_profit {0}; + string movies {"ABCD"}; + vector<int> showtimes {3, 6, 9, 12}; + vector<int> prices {25, 50, 75, 100}; + + cin >> k; + while (k--) + { + map<char, map<int, int>> 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<int> 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; +} |