結果
| 問題 |
No.180 美しいWhitespace (2)
|
| ユーザー |
uenoku
|
| 提出日時 | 2016-09-05 17:12:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,365 bytes |
| コンパイル時間 | 1,035 ms |
| コンパイル使用メモリ | 86,032 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-15 20:28:43 |
| 合計ジャッジ時間 | 1,737 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:60:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘lli’ {aka ‘long long int’} [-Wformat=]
60 | 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 = up - 1;
if (fx(up - 1) > fx(low + 1))
ans = low + 1;
if (ans <= 0)
ans = 1;
printf("%d\n", ans);
}
uenoku