pdpd123

Problem 10

Feb 17th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #pragma gcc optimze("Ofast")
  2. #pragma loop_opt(on)
  3. //#include <ext/pb_ds/assoc_container.hpp>
  4. //#include <ext/pb_ds/tree_policy.hpp>
  5. #include <bits/stdc++.h>
  6. #define debug(x) 1&&(cout<<#x<<':'<<x<<'\n')
  7. #define mkp make_pair
  8. #define pb emplace_back
  9. #define pf emplace_front
  10. #define ff first
  11. #define ss second
  12. #define siz(v) (ll(v.size()))
  13. #define all(v) begin(v),end(v)
  14. #define rall(v) rbegin(v),rend(v)
  15. #define REP(i,l,r) for(int i=(l);i<(r);i++)
  16. #define mid (l+(r-l>>1))
  17.  
  18. using namespace std;
  19. //using namespace __gnu_pbds;
  20. typedef long long ll;
  21. typedef long double ld;
  22. typedef pair<ll,ll> pll;
  23. //typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> rank_tree;
  24. //const long double PI = acos(-1),eps = 1e-8;
  25. constexpr ll N = 100000, INF = 1e18, MOD = 1000000007;
  26.  
  27. ll n,p=0,x,y;
  28. map<ll,ll> mp;
  29. pll stk[N+1] = {};
  30. ll cross(pll u,pll v){return u.ff*v.ss-u.ss*v.ff;}
  31. ll isConv(pll a,pll b,pll c){return cross(pll(b.ff-a.ff,b.ss-a.ss),pll(c.ff-b.ff,c.ss-b.ss))<0;}
  32. signed main(){
  33.     cin >> n;
  34.     REP(i,0,n){
  35.         cin >> x >> y, y-=x*x;
  36.         if(mp.count(x))mp[x] = max(mp[x],y);
  37.         else mp[x] = y;
  38.     }
  39.     for(auto dot:mp){
  40.         while(p>1 && !isConv(stk[p-2],stk[p-1],dot))--p;
  41.         stk[p++] = dot;
  42.     }
  43.     cout << p-1;
  44. }
Add Comment
Please, Sign In to add comment