ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#183171 | #3288. 恐狼前锋 | Hurry | 100 | 43ms | 4300kb | C++11 | 967b | 2023-08-08 10:06:07 | 2023-08-08 12:34:51 |
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#define int long long
using namespace std;
const int N=1e4+5;
struct node{
int id,slf,val;
bool operator<(const node &T)const{
return slf==T.slf?val>T.val:slf<T.slf;
}
};
__gnu_pbds::priority_queue<node> q;
__gnu_pbds::priority_queue<node>::point_iterator its[N];
int a[N],n,b[N];
bool del[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)cin>>a[i],ans+=a[i];
for(int i=1;i<=n;i++)cin>>b[i];
for(int i=1;i<=n;i++)its[i]=q.push((node){i,b[i],b[i-1]+b[i+1]});
while(not q.empty()){
int x=q.top().id;
ans+=q.top().val;q.pop();
del[x]=true;
int i=x;
if(i>1 and del[i-1]==false)q.modify(its[i-1],(node){i-1,b[i-1],(del[i-2]?0:b[i-2])});
if(i<n and del[i+1]==false)q.modify(its[i+1],(node){i+1,b[i+1],(del[i+2]?0:b[i+2])});
}
cout<<ans<<"\n";
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 2ms
memory: 3560kb
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: 3400kb
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: 1ms
memory: 3504kb
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: 0ms
memory: 3584kb
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: 2ms
memory: 3452kb
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: 4ms
memory: 4300kb
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: 4180kb
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: 8ms
memory: 4256kb
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: 4284kb
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: 4288kb
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"