QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202823 | #4647. Wavy Tree | yiyiyi# | WA | 61ms | 11424kb | C++14 | 893b | 2023-10-06 13:36:31 | 2023-10-06 13:36:31 |
Judging History
answer
#include <bits/stdc++.h>
#include <unordered_map>
#define int long long
#define inf 1e18
#define re register
#define N 1020203
using namespace std;
const int mo=1000000007;
inline int read(){
int x=0,w=0;char ch=getchar();
while (!isdigit(ch))w|=ch=='-',ch=getchar();
while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
return w?-x:x;
}
int a[N];
void solve(){
int n=read(),ans1=0,ans2=0;
for (int i=1;i<=n;++i)a[i]=read();
for (int i=2;i<=n;++i)
if (i&1){
if (a[i]>=a[i-1])ans1+=a[i]-a[i-1]+1,a[i]=a[i-1]-1;
}else{
if (a[i]<=a[i-1])ans1+=a[i-1]-a[i]+1,a[i]=a[i-1]+1;
}
for (int i=2;i<=n;++i)
if (i&1){
if (a[i]<=a[i-1])ans2+=a[i-1]-a[i]+1,a[i]=a[i-1]+1;
}else{
if (a[i]>=a[i-1])ans2+=a[i]-a[i-1]+1,a[i]=a[i-1]-1;
}
cout<<min(ans1,ans2)<<endl;
}
signed main(){
int T=read();
while (T--)solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 61ms
memory: 11424kb
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:
7349224094097 10532337049187 42013773340 94286536422238 304864037717 33310035291 27126085272 36045025116 3723809045964 6218175660020 27163006737 4061518843424 13450250708 39002357066 27114173348 8061969850 12017600169 29694865171 300714954028 44450326647 55925618694 20959122642 36417988055 306968957...
result:
wrong answer 1st lines differ - expected: '7254088195794', found: '7349224094097'