G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 4th, 2020 142 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define f first
  5. #define s second
  6. #define pb push_back
  7. #define FILL(a, b) memset(a, b, sizeof(a))
  8.  
  9. typedef long long int ll;
  10. typedef pair<int, int> pii;
  11. typedef pair<int, pii> piii;
  12. typedef vector<int> vi;
  13. typedef vector<pii> vii;
  14.  
  15. const int INF = 0x3f3f3f3f;
  16. const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
  17. const int MOD = 1e9 + 7;
  18. const int MAX = 1e5 + 5;
  19.  
  20. ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
  21. ll lcm(ll a, ll b){return a*b/gcd(a,b);}
  22. ll mul(ll a,ll b, ll M){if(b==0)return 0;ll t=mul(a,b/2,M);if(b&1)return (t+t+a)%M;return (t+t)%M;}
  23. ll fpow(ll a, ll b, ll M){if(b==0)return 1;ll t=fpow(a,b/2,M);if(b&1)return mul(mul(t,t,M),a,M)%M;return mul(t,t,M)%M;}
  24. ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
  25.  
  26. priority_queue<ll> g;
  27. int main() {
  28.     cin.sync_with_stdio(0);
  29.     cin.tie(0); cout.tie(0);
  30.     #ifndef ONLINE_JUDGE
  31.     freopen("../input.txt", "r", stdin);
  32.     freopen("../output.txt", "w", stdout);
  33.     #endif
  34.     int q, k; cin >> q >> k;
  35.     while(q--) {
  36.         int ch; cin >> ch;
  37.         if(ch == 1) {
  38.             int x, y; cin >> x >> y;
  39.             ll dist = x*x + y*y;
  40.             g.push(dist);
  41.             if(g.size() > k) {
  42.                 g.pop();
  43.             }
  44.         } else {
  45.             cout << g.top() << "\n";
  46.         }
  47.     }
  48.     return 0;
  49. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top