結果
| 問題 |
No.2648 [Cherry 6th Tune D] 一次元の馬
|
| コンテスト | |
| ユーザー |
rotti_coder
|
| 提出日時 | 2024-02-23 21:34:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 973 bytes |
| コンパイル時間 | 2,278 ms |
| コンパイル使用メモリ | 197,460 KB |
| 最終ジャッジ日時 | 2025-02-19 19:31:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 31 |
ソースコード
#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]+1e17;
for(int i=1;i<n;i++){
if(hako>=a[i]+(i+1)*1e17){
ok=true;
break;
}
hako=a[i]+(i+1)*1e17;
}
if(ok){
cout << -1 << endl;
continue;
}
left=0;
right=1e17;
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