Advertisement
OMEGAHEAD_MonkoX

Untitled

Oct 19th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <set>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. const long long int inf = 1000000000;
  9.  
  10. int find(set<long long int> a, long long int x)
  11. {
  12. /*
  13. int mi = 1000000001;
  14. for (auto i : a)
  15. if (i < mi && i >= x)
  16. mi = i;
  17. if (mi == 1000000001)
  18. return -1;
  19. return mi;
  20. */
  21. auto e = a.lower_bound(x);
  22. if (e == a.end())
  23. return -1;
  24. return *e;
  25.  
  26. }
  27.  
  28. int main()
  29. {
  30. set<long long int> a;
  31. long long int n, x, y;
  32. char ch, ch1;
  33. cin >> n;
  34. bool flag = false;
  35. for (long long int i = 0; i < n; ++i)
  36. {
  37. cin >> ch >> x;
  38. if (ch == '?')
  39. {
  40. flag = true;
  41. ch = '?';
  42. auto y1 = a.lower_bound(x);
  43. if (y1 == a.end()) y = -1; else y = *y1;
  44. cout << y << endl;
  45. }
  46.  
  47. if (ch == '+') {
  48. if (flag)
  49. a.insert((x + y) % (inf));
  50. else
  51. a.insert(x);
  52. flag = false;
  53. }
  54.  
  55. }
  56. }
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement