Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <set>
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- const long long int inf = 1000000000;
- int find(set<long long int> a, long long int x)
- {
- /*
- int mi = 1000000001;
- for (auto i : a)
- if (i < mi && i >= x)
- mi = i;
- if (mi == 1000000001)
- return -1;
- return mi;
- */
- auto e = a.lower_bound(x);
- if (e == a.end())
- return -1;
- return *e;
- }
- int main()
- {
- set<long long int> a;
- long long int n, x, y;
- char ch, ch1;
- cin >> n;
- bool flag = false;
- for (long long int i = 0; i < n; ++i)
- {
- cin >> ch >> x;
- if (ch == '?')
- {
- flag = true;
- ch = '?';
- auto y1 = a.lower_bound(x);
- if (y1 == a.end()) y = -1; else y = *y1;
- cout << y << endl;
- }
- if (ch == '+') {
- if (flag)
- a.insert((x + y) % (inf));
- else
- a.insert(x);
- flag = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement