ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183250 | #3288. 恐狼前锋 | abcad | 100 | 39ms | 3892kb | C++11 | 742b | 2023-08-08 11:48:27 | 2023-08-08 12:41:03 |
answer
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long LL;
typedef pair<LL,int> PLI;
const int N=10010;
int n;
LL a[N],b[N];
bool st[N];
int main()
{
LL ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%lld",&a[i]),ans+=a[i];
for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
priority_queue<PLI>heap;
for(int i=1;i<=n;i++)
heap.push({b[i],i});
while(heap.size())
{
PLI t=heap.top();
heap.pop();
LL v=t.first;
int ver=t.second;
if(st[ver])continue;
st[ver]=true;
b[ver]=0;
ans=ans+b[ver-1]+b[ver+1];
if(ver+1<=n&&(!st[ver+1]))heap.push({b[ver+1],ver+1});
if(ver-1>=1&&(!st[ver-1]))heap.push({b[ver-1],ver-1});
}
printf("%lld",ans);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 2ms
memory: 3444kb
input:
10 3 94 1981507 458857175 9 59165925 1 2591835 3622 16246 887096 695983 866 16 18 4212 405537627 102...
output:
523419627
result:
ok 1 number(s): "523419627"
Test #2:
score: 10
Accepted
time: 2ms
memory: 3552kb
input:
20 72 23 44 571921 1 7 4088128 677 508275894 458 8 88 7039 129116 5459 41858 12 15034308 192588188 1...
output:
769905926
result:
ok 1 number(s): "769905926"
Test #3:
score: 10
Accepted
time: 0ms
memory: 3524kb
input:
20 816 1 713239 32 1349392 3583 736305 706582161 80384 50465424 102 148 23346 1109 410639 27041 6765...
output:
1100807877
result:
ok 1 number(s): "1100807877"
Test #4:
score: 10
Accepted
time: 2ms
memory: 3472kb
input:
300 15 457 6004301 162473 9891 5 370410 2 7554233 957070 80775871 65 223203 30047785 1498968 1432 52...
output:
20024146273
result:
ok 1 number(s): "20024146273"
Test #5:
score: 10
Accepted
time: 1ms
memory: 3576kb
input:
300 1804 1732 427119741 3 450 2969441 3 1531710 124480 122087994 168990 1138758 3539 191721482 99978...
output:
14909163981
result:
ok 1 number(s): "14909163981"
Test #6:
score: 10
Accepted
time: 5ms
memory: 3796kb
input:
10000 45954200 9129 2152508 82 1976 28144715 22104 6592557 5002 44816 24699941 493469 653725 593399 ...
output:
617010943618
result:
ok 1 number(s): "617010943618"
Test #7:
score: 10
Accepted
time: 8ms
memory: 3892kb
input:
10000 9 582862 10895 575 1985 441608153 5794798 375427472 51382033 110855379 1360116 3214434 3369039...
output:
587536058523
result:
ok 1 number(s): "587536058523"
Test #8:
score: 10
Accepted
time: 3ms
memory: 3744kb
input:
10000 66999672 3958 8638582 6362 132947 3194964 21832 19303 41925606 60751 2 54059846 37542 75434693...
output:
585460842807
result:
ok 1 number(s): "585460842807"
Test #9:
score: 10
Accepted
time: 8ms
memory: 3736kb
input:
10000 40523 219765023 92678708 3 14 328202 326 58 610 4 38 28489100 4 389479 132199512 238106 22 868...
output:
593364318702
result:
ok 1 number(s): "593364318702"
Test #10:
score: 10
Accepted
time: 8ms
memory: 3868kb
input:
10000 57 101990 1775347 523038233 188544533 274 1167 28186 103 16418004 205401 1182379 6955 843 693 ...
output:
588056388069
result:
ok 1 number(s): "588056388069"