Advertisement
savrasov

D_sh

Oct 21st, 2017
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <cstring>
  5. #include <fstream>
  6. #include <cmath>
  7. #include <vector>
  8. #include <utility>
  9. #include <cstdlib>
  10. #include <deque>
  11. #include <queue>
  12. #include <iomanip>
  13. #include <numeric>
  14. #include <stack>
  15. #include <map>
  16. //#include <unordered_map>
  17. #include <set>
  18. //#include <unordered_set>
  19. #include <cmath>
  20. #include <list>
  21. #define mp make_pair
  22. #define pb push_back
  23. #define x first
  24. #define y second
  25. #define pnt pair<int, int>
  26. #define preturn(a) return cout << a << endl, 0
  27.  
  28. using namespace std;
  29.  
  30. typedef long long ll;
  31. typedef unsigned long long ull;
  32. typedef long double ld;
  33. typedef unsigned int uint;
  34. const int N = (int)250000, mdt = 1e7, limit = 1e8;
  35. const ld eps = 1e-8, eps1 = 1e-20, PI = 3.14159265358979323846264338, OOO = 1e100L, lim = sqrt(2e9 + 100);
  36. const ll OO = 1e18 * 8, mod = 1e9 + 7, md = 4294967291;
  37.  
  38. vector<pair<string, ld> > ans;
  39. map < string, ld>  a, b, num;
  40.  
  41. bool cmp(pair<string, ld> a, pair<string, ld> b)
  42. {
  43.     return (a.y > b.y) || (a.y == b.y && num[a.x] < num[b.x]);
  44. }
  45.  
  46. int main()
  47. {
  48.     ios_base::sync_with_stdio(0);
  49.     cin.tie();
  50.     cout.tie();
  51.     int n, m, r = 0, k;
  52.     string v, s;
  53.     cin >> n >> m >> v;
  54.     for (int i = 0; i < n; i++)
  55.     {
  56.         cin >> s >> k;
  57.         num[s] = r++;
  58.         ans.pb(mp(s, k));
  59.     }
  60.     r = 0;
  61.     for (int i = 0; i < n; i++)
  62.     {
  63.         cin >> s >> r >> k;
  64.         ans[num[s]].y += ((r - ans[num[s]].y) / k) * m;
  65.     }
  66.     sort(ans.begin(), ans.end(), cmp);
  67.     for (int i = 0; i < ans.size(); i++)
  68.         if (ans[i].x == v)
  69.             return cout << i + 1, 0;
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement