QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89899 | #5500. Bars | installb# | WA | 288ms | 5796kb | C++20 | 786b | 2023-03-21 18:43:30 | 2023-03-21 18:43:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define M 500005
using ll = long long;
int f[M],A[M],n,mark[M];
int main(){
int Cas;
cin>>Cas;
while(Cas--){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&A[i]),mark[i]=0;
ll ans = 0;
int mx = 0;
for(int i=1;i<=n;i++){
if(mx<A[i])mx = A[i],mark[i]=1;
}
mx=0;
for(int i=n;i>=1;i--){
if(mx<A[i])mx = A[i],mark[i]=1;
}
for(int i=1,last=0;i<=n;i++){
ans+=A[last];
if(mark[i])last=i;
}
A[n+1]=0;
for(int i=n,last=n+1;i>=1;i--){
ans+=A[last];
if(mark[i])last=i;
}
printf("%lld\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5796kb
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: 288ms
memory: 5720kb
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 381268324603 658930892444 543073796232 458946673513 296420749955 872966641760 630432425409 583595848800 225238172692 715347519911 462034667948 273545943459 585094154153 200443831314 336548821022 483213442818 602558460217 586771956643 400264139273 826365121407 975377092201 920978353624 26408806...
result:
wrong answer 3rd lines differ - expected: '382465638565', found: '381268324603'