QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#298299 | #5500. Bars | 0xyz | WA | 196ms | 7872kb | C++14 | 506b | 2024-01-05 23:20:30 | 2024-01-05 23:20:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll _=5e5+5;
ll n,t,f[_],p[_],v,T,s[_],g[_];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
cin>>n;
for(ll i=1;i<=n;i++)cin>>p[i],f[i]=0;
g[1]=1;
for(ll i=2;i<=n;i++){
g[i]=g[i-1];
for(ll j=g[i-1]+1;j<i;j++)
if((i-j)*(p[i]+p[j])+f[j]>=(i-g[i])*(p[i]+p[g[i]])+f[g[i]])g[i]=j;
f[i]=(i-g[i])*(p[i]+p[g[i]])+f[g[i]];
}
cout<<f[n]<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7708kb
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: 196ms
memory: 7872kb
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 225238173558 548995280859 372195572969 228928264291 585094154153 158133693702 336548825942 374347211592 487728425474 465074500144 356621942568 632295317148 733272508643 696364797312 26408806...
result:
wrong answer 3rd lines differ - expected: '382465638565', found: '323902577661'