結果
| 問題 |
No.180 美しいWhitespace (2)
|
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-09-22 21:48:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,879 bytes |
| コンパイル時間 | 1,595 ms |
| コンパイル使用メモリ | 170,068 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 13:18:33 |
| 合計ジャッジ時間 | 32,497 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef long double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
auto i = vs.begin();
os << "[" << *i;
for (++i; i != vs.end(); ++i) os << " " << *i;
return os << "]";
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
const ll INF = LLONG_MAX / 2LL;
int N;
vector<ll> A, B;
void input() {
cin >> N;
A.resize(N);
B.resize(N);
for (int i = 0; i < N; i++) {
cin >> A[i] >> B[i];
}
}
ll C(ll x) {
ll m = INF;
ll M = 0;
for (int i = 0; i < N; i++) {
m = min(m, A[i] + B[i] * x);
M = max(M, A[i] + B[i] * x);
}
//cout << x << " -> " << M - m << endl;
return M - m;
}
void solve() {
if (N == 1) {
cout << 1 << endl;
return;
}
ll len = C(1);
ll t = 1;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (B[i] == B[j]) continue;
ll x = - (A[i] - A[j]) / real(B[i] - B[j]);
if (x <= 0) continue;
ll y = floor(x);
for (ll dy = -2; dy <= 2; dy++) {
ll p = C(y + dy);
if (len > p) {
len = p;
t = y + dy;
} else if (len == p) {
t = min(t, y + dy);
}
}
}
}
cout << t << endl;
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura