結果
問題 | No.180 美しいWhitespace (2) |
ユーザー |
![]() |
提出日時 | 2016-09-05 17:16:56 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 1,393 bytes |
コンパイル時間 | 651 ms |
コンパイル使用メモリ | 84,376 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 20:28:47 |
合計ジャッジ時間 | 1,691 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:63:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘lli’ {aka ‘long long int’} [-Wformat=] 63 | printf("%d\n", ans); | ~^ ~~~ | | | | int lli {aka long long int} | %lld
ソースコード
#include "math.h" #include <algorithm> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define ifor(i, a, b) for (int i = (a); i < (b); i++) #define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define INF 1e18 using namespace std; typedef long double ld; typedef long long int lli; typedef complex<double> P; const double eps = 1e-11; int vex[4] = {1, 0, -1, 0}; int vey[4] = {0, 1, 0, -1}; typedef vector<double> Vec; typedef vector<int> vec; typedef vector<Vec> MAT; typedef vector<vec> mat; lli MOD = 1000000007; int N; lli a[1001], b[1001]; lli f(lli A, lli B, lli x) { return (A + B * x); } lli fx(lli x) { lli c = -INF, d = INF; rep(i, N) c = max(c, f(a[i], b[i], x)); rep(i, N) d = min(d, f(a[i], b[i], x)); return c - d; } int main() { cin >> N; rep(i, N) cin >> a[i] >> b[i]; lli up = 1e9, low = -1; rep(i, 100) { lli t31 = (up + 2 * low) / 3, t32 = (up * 2 + low) / 3; if (fx(t31) > fx(t32)) low = t31; else up = t32; } lli ans = low; rep(i, 4) { if (fx(ans) > fx(low + i)) ans = low + i; } if (ans <= 0) ans = 1; printf("%d\n", ans); }