fork download
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. #define pii pair<int,int>
  4. #define fi first
  5. #define se second
  6. using namespace std;
  7. using ll = long long;
  8. const int maxN = 1e6 + 5;
  9. const ll infty = 1e18 + 5;
  10. const int mod = 998244353;
  11.  
  12. void Input()
  13. {
  14. //freopen("test.inp","r",stdin);
  15. }
  16.  
  17. int n;
  18. set<int> st;
  19.  
  20. void Solve(int tt)
  21. {
  22. cin >> n;
  23. while(n--)
  24. {
  25. int x;
  26. cin >> x;
  27. st.insert(x);
  28. }
  29. string order;
  30. int x;
  31. while(cin >> order)
  32. {
  33. if(order == "#") break;
  34. cin >> x;
  35. if(order == "insert") st.insert(x);
  36. else if(order == "min_greater_equal")
  37. {
  38. auto it = st.lower_bound(x);
  39. if(it == st.end())
  40. {
  41. cout <<"NULL"<<'\n';
  42. }
  43. else
  44. {
  45. cout << *it <<'\n';
  46. }
  47. }
  48. else if(order == "min_greater")
  49. {
  50. auto it = st.upper_bound(x);
  51. if(it == st.end())
  52. {
  53. cout <<"NULL"<<'\n';
  54. }
  55. else
  56. {
  57. cout << *it <<'\n';
  58. }
  59. }
  60. else if(order == "remove")
  61. {
  62. st.erase(x);
  63. }
  64. }
  65. }
  66.  
  67. int32_t main()
  68. {
  69. ios_base::sync_with_stdio(false);
  70. cin.tie(nullptr);
  71.  
  72. int test = 1;
  73. //cin >> test;
  74. int tt = 1;
  75. while(test--)
  76. {
  77. Solve(tt++);
  78. }
  79. }
  80.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty