結果
| 問題 |
No.2648 [Cherry 6th Tune D] 一次元の馬
|
| コンテスト | |
| ユーザー |
rotti_coder
|
| 提出日時 | 2024-02-23 21:38:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 237 ms / 2,000 ms |
| コード長 | 990 bytes |
| コンパイル時間 | 1,533 ms |
| コンパイル使用メモリ | 198,360 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 02:02:08 |
| 合計ジャッジ時間 | 6,397 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t,n;
cin >> t;
vector<long long>a;
bool ok;
long long hako,left,right,mokuteki;
for(int q=0;q<t;q++){
a.clear();
cin >> n;
for(int i=0;i<n;i++){
cin >> hako;
a.emplace_back(hako);
}
ok=true;
for(int i=0;i<n-1;i++)if(a[i]>=a[i+1])ok=false;
if(ok){
cout << 0 << endl;
continue;
}
ok=false;
hako=a[0]+1e9+100;
for(int i=1;i<n;i++){
if(hako>=a[i]+(i+1)*(1e9+100)){
ok=true;
break;
}
hako=a[i]+(i+1)*(1e9+100);
}
if(ok){
cout << -1 << endl;
continue;
}
left=0;
right=1e9+100;
while(left+1!=right){
mokuteki=(left+right)/2;
hako=a[0]+mokuteki;
ok=true;
for(int i=1;i<n;i++){
if(hako>=a[i]+(i+1)*mokuteki){
ok=false;
break;
}
hako=a[i]+(i+1)*mokuteki;
}
if(ok)right=mokuteki;
else left=mokuteki;
}
cout << right << endl;
}
return 0;
}
rotti_coder