結果
問題 | No.180 美しいWhitespace (2) |
ユーザー | srup٩(๑`н´๑)۶ |
提出日時 | 2016-09-23 00:54:28 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 989 bytes |
コンパイル時間 | 482 ms |
コンパイル使用メモリ | 61,664 KB |
実行使用メモリ | 10,140 KB |
最終ジャッジ日時 | 2024-04-28 20:21:37 |
合計ジャッジ時間 | 7,088 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | TLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
ソースコード
#include <iostream> #include <cstdio> #include <set> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) const ll INF = 1e12; int n; ll a[1010], b[1010]; ll search(ll m){ ll ma = 0, mi = INF; rep(i, n){ ll num = a[i] + b[i] * m; ma = max(ma, num); mi = min(mi, num); } return ma - mi; } int main(void){ cin >> n; bool flag = true; rep(i, n){ cin >> a[i] >> b[i]; if(!(a[i] == 0 && b[i] == 0)) flag = false; } if(flag){ printf("1\n"); return 0; } //下とつ ll l = 1, r = INF; while(r - l > 3){ ll m1 = (l * 2 + r) / 3; ll m2 = (l + r * 2) / 3; if(search(m1) >= search(m2)){//左側が高い l = m1; }else{//右側が高い r = m2; } } ll ans = l, minn = INF; // printf("k %d %d\n", l, r); for (int i = l; i <= r; ++i){ ll t = search(i); if(minn > t){ minn = t; ans = i; } } printf("%lld\n", ans); return 0; }