QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#298298#5500. Bars0xyzWA 187ms5960kbC++14463b2024-01-05 23:17:492024-01-05 23:17:50

Judging History

This is the latest submission verdict.

  • [2024-01-05 23:17:50]
  • Judged
  • Verdict: WA
  • Time: 187ms
  • Memory: 5960kb
  • [2024-01-05 23:17:49]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll _=5e5+5;
ll n,t,f[_],p[_],g[_];
ll w(ll x,ll y){
	return f[x]+(y-x)*(p[x]+p[y]);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0); 
	cin>>t;
	while(t--){
		cin>>n;g[1]=1;
		for(ll i=1;i<=n;i++)cin>>p[i];
		for(ll i=2;i<=n;i++)
			if(w(i-1,i)<w(g[i-1],i))g[i]=g[i-1],f[i]=w(g[i-1],i);
			else g[i]=i-1,f[i]=w(i-1,i);
		cout<<f[n]<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5600kb

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: 187ms
memory: 5960kb

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'