結果
| 問題 |
No.2648 [Cherry 6th Tune D] 一次元の馬
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2024-02-23 21:31:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 325 ms / 2,000 ms |
| コード長 | 984 bytes |
| コンパイル時間 | 2,074 ms |
| コンパイル使用メモリ | 196,212 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 02:01:19 |
| 合計ジャッジ時間 | 7,667 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
#ifdef LOCAL
#include "./debug.cpp"
#else
#define debug(...)
#define print_line
#endif
using namespace std;
using ll = long long;
bool check(const vector<ll> &a) {
bool ok = true;
for (int i = 0; i < a.size() - 1; i++) ok &= a[i] < a[i + 1];
return ok;
}
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<ll> A(N);
for (int i = 0; i < N; i++) cin >> A[i];
if (check(A)) {
cout << 0 << '\n';
continue;
}
ll lo = -1, hi = 2e9;
while (hi - lo > 1) {
ll mid = (lo + hi) / 2;
vector<ll> B(N);
for (int i = 0; i < N; i++) B[i] = A[i] + mid * i;
if (check(B)) {
hi = mid;
} else {
lo = mid;
}
}
if (lo == -1) {
cout << -1 << '\n';
} else {
cout << hi << '\n';
}
}
}
Today03