結果
問題 | No.180 美しいWhitespace (2) |
ユーザー |
![]() |
提出日時 | 2015-04-05 23:58:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 72 ms / 5,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 1,137 ms |
コンパイル使用メモリ | 158,460 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 02:16:51 |
合計ジャッジ時間 | 3,225 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%lld %lld", a+i, b+i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; const int MAXN = 1020; ll a[MAXN], b[MAXN]; int N; ll get(ll x) { ll ret = 0; for (int i = 0; i < N; i++) { for (int j = i+1; j < N; j++) { ret = max(ret, abs((b[i]-b[j]) * x + (a[i]-a[j]))); } } return ret; } int main() { cin >> N; for (int i = 0; i < N; i++) { scanf("%lld %lld", a+i, b+i); } ll low = 1, high = 1e9+7; while (high-low > 2) { ll m1 = (high+low*2) / 3; ll m2 = (high*2+low) / 3; if (get(m1) <= get(m2)) high = m2; else low = m1; } if (get(low) <= get(high-1)) cout << low << endl; else cout << high-1 << endl; return 0; }