QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100300 | #4647. Wavy Tree | euphria# | WA | 249ms | 18880kb | C++20 | 1.4kb | 2023-04-25 15:26:51 | 2023-04-25 15:26:52 |
Judging History
answer
//B站关注 艾尔莎 喵
//All OK
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define ios ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(0);cout << fixed << setprecision(9)
#define INF 1ll*1e10
#define LNF (1ll << 60)
#define PII pair<int, int>
#define PI acos(-1)
#define ll long long
// #define ll __int128
#define int ll
#define endl '\n'
using namespace std;
const int N = 1e6 + 10;
int n;
ll a[N], b[N];
void solve(){
ll ans = INF;
cin >> n;
for(int i = 1; i <= n; i ++)
cin >> a[i];
b[1] = a[1];
ll res = 0;
for(int i = 2; i <= n; i ++){
b[i] = a[i];
if(i % 2 && b[i - 1] <= b[i])
res += b[i] - b[i - 1] + 1, b[i] = b[i - 1] - 1;
else if(i % 2 == 0 && b[i - 1] >= b[i])
res += b[i - 1] - b[i] + 1, b[i] = b[i - 1] + 1;
}
ans = min(ans, res);
res = 0;
for(int i = 2; i <= n; i ++){
b[i] = a[i];
if(i % 2 && b[i - 1] >= b[i])
res += b[i - 1] - b[i] + 1, b[i] = b[i - 1] + 1;
else if(i % 2 == 0 && b[i - 1] <= b[i])
res += b[i] - b[i - 1] + 1, b[i] = b[i - 1] - 1;
}
cout << min(ans, res) << endl;
}
signed main(){
ios;
// init();
int _ = 1;
cin >> _;
for(int __ = 1; __ <= _; __ ++){
// cout << "Case " << __ << ": ";
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 249ms
memory: 18880kb
input:
1000 100000 421811673 163389757 362117917 679743722 325614744 632629964 980475526 100505548 936347880 928352466 107919751 93875425 790807861 179598820 105172240 143240481 781447901 225995680 495635141 806359893 572331818 169913092 230473678 658931041 285082875 709115692 204427990 675460241 498216193...
output:
10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 4819422928 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 10000000000 1...
result:
wrong answer 1st lines differ - expected: '7254088195794', found: '10000000000'