Vserosbuybuy

C4. E

Mar 16th, 2021
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <vector>
  4. #include <map>
  5. #include <math.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. map<int, vector<string>> mp;
  11.  
  12. int main()
  13. {
  14. #if _DEBUG
  15.     freopen("input.txt", "r", stdin);
  16.     freopen("output.txt", "w", stdout);
  17. #endif
  18.     int n, m, x;
  19.     cin >> n >> m;
  20.     string w;
  21.     vector<int> start(m);
  22.     cin >> w;
  23.     for (int j = 0; j < m; ++j) {
  24.         cin >> start[j];
  25.     }
  26.     vector<int> tmp(m);
  27.    
  28.     int maxx = -1e9;
  29.     vector<string> ans;
  30.     for (int i = 0; i < n - 1; ++i) {
  31.         cin >> w;
  32.         for (int j = 0; j < m; ++j) {
  33.             cin >> tmp[j];
  34.         }
  35.  
  36.         int sc = 0;
  37.         for (int j = 0; j < m; ++j) {
  38.             sc += start[j] * tmp[j];
  39.         }
  40.  
  41.         if (sc > maxx) {
  42.             ans.clear();
  43.             ans.push_back(w);
  44.             maxx = sc;
  45.         }
  46.         else if (sc == maxx) {
  47.             ans.push_back(w);
  48.         }
  49.     }
  50.  
  51.     for (auto x : ans) {
  52.         cout << x << "\n";
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment