結果
問題 | No.2012 Largest Triangle |
ユーザー | shotoyoo |
提出日時 | 2022-07-15 22:04:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,805 bytes |
コンパイル時間 | 2,317 ms |
コンパイル使用メモリ | 207,840 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-27 18:03:24 |
合計ジャッジ時間 | 6,456 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
ソースコード
bool TEST = false; using namespace std; #include<bits/stdc++.h> #include<fstream> #define rep(i,n) for(ll (i)=0;(i)<(ll)(n);i++) #define rrep(i,n) for(ll (i)=(ll)(n)-1;(i)>=0;i--) #define range(i,start,end,step) for(ll (i)=start;(i)<(ll)(end);(i)+=(step)) #define rrange(i,start,end,step) for(ll (i)=start;(i)>(ll)(end);(i)+=(step)) #define dump(x) cerr << "Line " << __LINE__ << ": " << #x << " = " << (x) << "\n"; #define spa << " " << #define fi first #define se second #define all(a) (a).begin(),(a).end() #define allr(a) (a).rbegin(),(a).rend() using ld = long double; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; template<typename T> using V = vector<T>; template<typename T> using VV = V<V<T>>; template<typename T, typename T2> using P = pair<T, T2>; template<typename T, typename T2> using M = map<T, T2>; template<typename T> using S = set<T>; template<typename T, typename T2> using UM = unordered_map<T, T2>; template<typename T> using PQ = priority_queue<T, V<T>, greater<T>>; template<typename T> using rPQ = priority_queue<T, V<T>, less<T>>; template<class T>vector<T> make_vec(size_t a){return vector<T>(a);} template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));} template<class SS, class T> ostream& operator << (ostream& os, const pair<SS, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;} template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; } template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;} struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; template <class T> void UNIQUE(vector<T> &x) {sort(all(x));x.erase(unique(all(x)), x.end());} template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } void fail() { cout << -1 << '\n'; exit(0); } inline int popcount(const int x) { return __builtin_popcount(x); } inline int popcount(const ll x) { return __builtin_popcountll(x); } template<typename T> void debug(vector<vector<T>>&v){for(ll i=0;i<v.size();i++) {cerr<<v[i][0];for(ll j=1;j<v[i].size();j++)cerr spa v[i][j];cerr<<"\n";}}; template<typename T> void debug(vector<T>&v){if(v.size()!=0)cerr<<v[0]; for(ll i=1;i<v.size();i++)cerr spa v[i]; cerr<<"\n";}; template<typename T> void debug(priority_queue<T>&v){V<T> vals; while(!v.empty()) {cerr << v.top() << " "; vals.push_back(v.top()); v.pop();} cerr<<"\n"; for(auto val: vals) v.push(val);} template<typename T, typename T2> void debug(map<T,T2>&v){for(auto [k,v]: v) cerr << k spa v << "\n"; cerr<<"\n";} template<typename T, typename T2> void debug(unordered_map<T,T2>&v){for(auto [k,v]: v) cerr << k spa v << "\n";cerr<<"\n";} V<int> listrange(int n) {V<int> res(n); rep(i,n) res[i]=i; return res;} template<typename T> P<T,T> divmod(T a, T b) {return make_pair(a/b, a%b);} const ll INF = (1ll<<62); // const ld EPS = 1e-10; // const ld PI = acos(-1.0); // double /** * @brief Dynamic-Li-Chao-Tree * @docs docs/dynamic-li-chao-tree.md */ template< typename T, ll _x_low, ll _x_high, ll id > struct DynamicLiChaoTree { T x_low, x_high; struct Line { T a, b; Line(T a, T b) : a(a), b(b) {} inline T get(T x) const { return a * x + b; } }; struct Node { Line x; Node *l, *r; Node(const Line &x) : x{x}, l{nullptr}, r{nullptr} {} }; Node *root; DynamicLiChaoTree() : root{nullptr} { x_low = _x_low; x_high = _x_high; } Node *add_line(Node *t, Line &x, const T &l, const T &r, const T &x_l, const T &x_r) { if(!t) return new Node(x); T t_l = t->x.get(l), t_r = t->x.get(r); if(t_l <= x_l && t_r <= x_r) { return t; } else if(t_l >= x_l && t_r >= x_r) { t->x = x; return t; } else { T m = (l + r) / 2; if(m == r) --m; T t_m = t->x.get(m), x_m = x.get(m); if(t_m > x_m) { swap(t->x, x); if(x_l >= t_l) t->l = add_line(t->l, x, l, m, t_l, t_m); else t->r = add_line(t->r, x, m + 1, r, t_m + x.a, t_r); } else { if(t_l >= x_l) t->l = add_line(t->l, x, l, m, x_l, x_m); else t->r = add_line(t->r, x, m + 1, r, x_m + x.a, x_r); } return t; } } void add_line(const T &a, const T &b) { Line x(a, b); root = add_line(root, x, x_low, x_high, x.get(x_low), x.get(x_high)); } Node *add_segment(Node *t, Line &x, const T &a, const T &b, const T &l, const T &r, const T &x_l, const T &x_r) { if(r < a || b < l) return t; if(a <= l && r <= b) { Line y{x}; return add_line(t, y, l, r, x_l, x_r); } if(t) { T t_l = t->x.get(l), t_r = t->x.get(r); if(t_l <= x_l && t_r <= x_r) return t; } else { t = new Node(Line(0, id)); } T m = (l + r) / 2; if(m == r) --m; T x_m = x.get(m); t->l = add_segment(t->l, x, a, b, l, m, x_l, x_m); t->r = add_segment(t->r, x, a, b, m + 1, r, x_m + x.a, x_r); return t; } void add_segment(const T &l, const T &r, const T &a, const T &b) { Line x(a, b); root = add_segment(root, x, l, r - 1, x_low, x_high, x.get(x_low), x.get(x_high)); } T query(const Node *t, const T &l, const T &r, const T &x) const { if(!t) return id; if(l == r) return t->x.get(x); T m = (l + r) / 2; if(m == r) --m; if(x <= m) return min(t->x.get(x), query(t->l, l, m, x)); else return min(t->x.get(x), query(t->r, m + 1, r, x)); } T query(const T &x) const { return query(root, x_low, x_high, x); } }; // // cannot overflow query_x*xlow, query_x*xhigh // DynamicLiChaoTree<ll, 0, ll(1e12+10), INF> t; // <type, xlow, xhigh, id> // t.add_line(a,b); // t.query(x); // // cannot overflow query_x*xlow, query_x*xhigh // t.add_line(a,b); // t.query(x); void Main(){ ll n; cin >> n; DynamicLiChaoTree<double, 0, ll(1e12+10), INF> t; // <type, xlow, xhigh, id> ll x,y; ll ans = 0; rep(i,n) { cin >> x >> y; if (i>0) chmax(ans, ll(abs(double(x) * t.query(double(y)/double(x)))*2 + 0.0001)); t.add_line(y, -x); t.add_line(-y, x); } cout << ans << "\n"; } int main(void){ std::ifstream in("tmp_in"); if (TEST) { std::cin.rdbuf(in.rdbuf()); std::cout << std::fixed << std::setprecision(15); } else { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); } Main(); }