結果
| 問題 |
No.1715 Dinner 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-22 22:05:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 885 bytes |
| コンパイル時間 | 1,538 ms |
| コンパイル使用メモリ | 169,060 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-23 05:36:10 |
| 合計ジャッジ時間 | 2,686 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 WA * 3 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;
typedef long long ll;
int main() {
ll N, D;
cin >> N >> D;
vector<ll> P(N), Q(N);
rep(i, 0, N) cin >> P[i] >> Q[i];
ll ans = -1e18;
rep(i, 0, N) {
rep(j, 0, N) {
if (i == j) continue;
ll x = - P[i] + Q[i] - P[j] + Q[j];
if (x >= 0) {
ans = max(ans, min(- P[i], - P[i] + Q[i] - P[j]));
} else {
if (D % 2) {
ll y = x * (D / 2 - 1) - P[i] + Q[i];
ans = max(ans, min({0LL, y - P[j], y - P[j] + Q[j] - P[i]}));
} else {
ll y = x * (D / 2 - 1);
ans = max(ans, min({0LL, y - P[i], y - P[i] + Q[i] - P[j]}));
}
}
}
}
cout << ans << endl;
}