Advertisement
savrasov

D_school

Oct 22nd, 2017
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. #define mp make_pair
  7. #define pb push_back
  8. #define x first
  9. #define y second
  10.  
  11. using namespace std;
  12.  
  13. typedef long double ld;
  14. vector<pair<string, ld> > ans;
  15. map <string, ld>  a, b, num;
  16.  
  17. bool cmp(pair<string, ld> a, pair<string, ld> b)
  18. {
  19.     return (a.y > b.y) || (a.y == b.y && num[a.x] < num[b.x]);
  20. }
  21.  
  22. int main()
  23. {
  24.     ios_base::sync_with_stdio(0);
  25.     cin.tie();
  26.     cout.tie();
  27.     int n, m, r = 0, k;
  28.     string v, s;
  29.     cin >> n >> m >> v;
  30.     for (int i = 0; i < n; i++)
  31.     {
  32.         cin >> s >> k;
  33.         num[s] = r++;
  34.         ans.pb(mp(s, k));
  35.     }
  36.     r = 0;
  37.     for (int i = 0; i < n; i++)
  38.     {
  39.         cin >> s >> r >> k;
  40.         ans[num[s]].y += ((r - ans[num[s]].y) / k) * m;
  41.     }
  42.     sort(ans.begin(), ans.end(), cmp);
  43.     for (int i = 0; i < ans.size(); i++)
  44.         if (ans[i].x == v)
  45.             return cout << i + 1, 0;
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement