Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream f("ramen.in");
  6. ofstream g("ramen.out");
  7.  
  8. const int N = 100010;
  9.  
  10. int n, T, tp, po, i, sol[N];
  11. set< tuple < int, int, int > > clienti;
  12. set< int > farfurii;
  13.  
  14. int main()
  15. {
  16. f >> n >> T;
  17.  
  18. for(i = 1; i <= n; i++)
  19. {
  20. f >> tp >> po;
  21. clienti.insert(make_tuple(po, tp, i));
  22. farfurii.insert(tp);
  23. }
  24. for(auto it:clienti)
  25. {
  26. tie(po, tp, i)=it;
  27. set<int>::iterator IT = farfurii.lower_bound(tp - po - T);
  28. sol[i] = *IT + T + po;
  29. farfurii.erase(*IT);
  30. }
  31.  
  32. for(i = 1; i <= n; i++)
  33. g << sol[i] <<'\n';
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement