QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#153607 | #5500. Bars | Knight | WA | 219ms | 6000kb | C++14 | 639b | 2023-08-30 13:36:52 | 2023-08-30 13:36:52 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;
const int N=1e6+10;
int T,n,a[N],stk[N],tt;
int V(int x,int y){
return (y-x)*(a[x]+a[y]);
}
signed main(){
scanf("%lld",&T);
while(T--){
tt=0;
scanf("%lld",&n);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
stk[++tt]=1;int ans=0;
for(int i=2;i<=n;i++){
if(tt>=2&&V(stk[tt-1],stk[tt])+V(stk[tt],i)<=V(stk[tt-1],i)) tt--;
stk[++tt]=i;
}
for(int i=2;i<=tt;i++) ans+=V(stk[i-1],stk[i]);
for(int i=1;i<=tt;i++) stk[i]=0;
printf("%lld\n",ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5880kb
input:
2 4 5 2 2 6 5 1 5 4 4 1
output:
33 29
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 219ms
memory: 6000kb
input:
10000 4 5 2 2 6 5 1 5 4 4 1 197 763787596 15221694 898228999 187472305 466351873 822742732 437754202 800092772 843092246 915675776 166265020 346340615 796714085 497548541 182089610 64356048 363276768 181268733 257949015 236568898 752096761 928725929 443146784 114577469 833053207 38120723 14891030 41...
output:
33 29 323902577661 517310514769 442743983454 458946673513 296420749955 684398023821 488908817507 452497461066 225238173573 548995280859 372195572969 228928264291 585094154153 158133693702 336548826266 374347211592 487728425474 465074500144 356621942568 632295317148 733272508643 696364797312 26408806...
result:
wrong answer 3rd lines differ - expected: '382465638565', found: '323902577661'