Advertisement
vitormartinotti

solveit

Jun 24th, 2024
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. set<int> s;
  5.  
  6. int main() {
  7. //set + lower_bound
  8.    int n, q; scanf("%d %d", &n, &q);
  9.  
  10.    while(q--){
  11.  
  12.       int k, y; scanf("%d %d", &k, &y);
  13.  
  14.       if(k == 1){
  15.          s.insert(y);
  16.       }
  17.       else{
  18.          auto resp = s.lower_bound(y);
  19.          if(resp != s.end()){
  20.             printf("%d\n", *resp);
  21.  
  22.          }
  23.          else{
  24.             printf("-1\n");
  25.          }
  26.       }
  27.    }
  28.  
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement