fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int n, k;
  5. cin >> n >> k;
  6. set<int> ss;
  7. while(n--)
  8. {
  9. int a, b, c;
  10. cin >> a;
  11. if(a==1)
  12. {
  13. cin >> b >> c;
  14. int x = (b*b) + (c*c);
  15. if(ss.size()<k) ss.insert(x);
  16.  
  17.  
  18. else
  19. {
  20. set<int>::iterator toko = --ss.end();
  21. ss.erase(*toko);
  22. ss.insert(x);
  23. }
  24. }
  25.  
  26. else
  27. {
  28. set<int>::iterator toko = --ss.end();
  29. cout << *toko << endl ;
  30. }
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 4496KB
stdin
Standard input is empty
stdout
Standard output is empty