Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- using namespace std;
- /*
- bool operator < (const RatingIndex& lhs, const RatingIndex& rhs) {
- if (lhs.rating != rhs.rating) {
- return lhs.rating < rhs.rating;
- }
- return lhs.index > rhs.index;
- }
- bool operator > (const RatingIndex& lhs, const RatingIndex& rhs) {
- if (lhs.rating != rhs.rating) {
- return lhs.rating > rhs.rating;
- }
- return lhs.index < rhs.index;
- }
- void quicksort(vector<RatingIndex>& arr, int low, int high) {
- if (low > high) {
- return;
- }
- int pivotindex = low + (high - low) / 2; int i = low; int j = high; RatingIndex z;
- RatingIndex pivotelement = arr[pivotindex];
- while (i <= j) {
- while (arr[i] < pivotelement) {
- i++;
- }
- while (arr[j] > pivotelement) {
- j--;
- }
- if (i <= j) {
- z = arr[i];
- arr[i] = arr[j];
- arr[j] = z;
- i++;
- j--;
- }
- }
- quicksort(arr, low, j);
- quicksort(arr, i, high);
- }
- */
- struct RatingIndex {
- int64_t rating;
- int64_t index;
- };
- int main() {
- int critics_count, films_count, top_size;
- cin >> critics_count >> films_count >> top_size;
- vector<int64_t> authorities(critics_count);
- for (int64_t& authority : authorities) {
- cin >> authority;
- }
- vector<RatingIndex> ratings_indexies(films_count);
- for (int i = 0; i < films_count; i++) {
- ratings_indexies[i].index = i;
- ratings_indexies[i].rating = 0;
- for (int64_t authority : authorities) {
- int64_t score;
- cin >> score;
- ratings_indexies[i].rating += authority * score;
- ratings_indexies[i].rating %= 1000000007;
- }
- }
- sort(begin(ratings_indexies), end(ratings_indexies), [](const auto& lhs, const auto& rhs) {
- if (lhs.rating != rhs.rating) {
- return lhs.rating > rhs.rating;
- }
- return lhs.index < rhs.index;
- });
- for (int i = 0; i < top_size; i++) {
- cout << ratings_indexies[i].index + 1 << ' ';
- }
- }
- /*
- 6 4 2
- 5 1 2 0 2 4
- 1 0 9 2 9 5
- 5 5 2 0 5 2
- 2 7 2 2 5 2
- 5 2 4 2 2 5
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement