結果
問題 | No.2012 Largest Triangle |
ユーザー | tnakao0123 |
提出日時 | 2024-07-24 09:46:22 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,627 bytes |
コンパイル時間 | 840 ms |
コンパイル使用メモリ | 64,308 KB |
実行使用メモリ | 9,776 KB |
最終ジャッジ日時 | 2024-07-24 09:46:28 |
合計ジャッジ時間 | 5,797 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 3 ms
7,492 KB |
testcase_06 | WA | - |
testcase_07 | AC | 3 ms
7,492 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | WA | - |
testcase_13 | AC | 2 ms
6,948 KB |
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 | AC | 3 ms
6,944 KB |
testcase_37 | AC | 3 ms
6,940 KB |
testcase_38 | AC | 3 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,944 KB |
testcase_40 | AC | 3 ms
6,944 KB |
testcase_41 | AC | 19 ms
6,944 KB |
ソースコード
/* -*- coding: utf-8 -*- * * 2012.cc: No.2012 Largest Triangle - yukicoder */ #include<cstdio> #include<cmath> #include<algorithm> #include<utility> using namespace std; /* constant */ const int MAX_N = 200000; const long long LINF = 1LL << 60; /* typedef */ using ll = long long; using pdi = pair<double,int>; /* global variables */ ll xs[MAX_N], ys[MAX_N]; pdi tis[MAX_N]; /* subroutines */ inline ll cross(int i, int j) { return xs[i] * ys[j] - xs[j] * ys[i]; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%lld%lld", xs + i, ys + i); for (int i = 0; i < n; i++) tis[i] = {atan2(ys[i], xs[i]), i}; sort(tis, tis + n); ll minc = 0, maxc = 0; int j0 = 0, j1 = 0; for (int j = 1; j < n; j++) { ll c = cross(tis[0].second, tis[j].second); //printf(" c=%lld,j=%d\n", c, j); if (minc > c) minc = c, j0 = j; if (maxc < c) maxc = c, j1 = j; } //printf("minc=%lld,j0=%d maxc=%lld,j1=%d\n", minc, j0, maxc, j1); for (int i = n - 1; i > 0; i--) { ll c0 = cross(tis[i].second, tis[j0].second); while (j0 != i) { int jj = (j0 + n + 1) % n; ll cc = cross(tis[i].second, tis[jj].second); if (cc >= c0) break; c0 = cc, j0 = jj; } minc = min(minc, c0); } for (int i = 1; i < n; i++) { ll c1 = cross(tis[i].second, tis[j1].second); while (j1 != i) { int jj = (j1 + 1) % n; ll cc = cross(tis[i].second, tis[jj].second); if (cc <= c1) break; c1 = cc, j1 = jj; } maxc = max(maxc, c1); } ll maxs = max(-minc, maxc); printf("%lld\n", maxs); return 0; }