ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183181 | #3288. 恐狼前锋 | Xepcs | 100 | 26ms | 3808kb | C++11 | 1.2kb | 2023-08-08 10:19:46 | 2023-08-08 12:35:43 |
answer
#include<bits/stdc++.h>
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define DU double
#define rep(i,x,n) for(int i=(x);i<=(n);i++)
#define nep(i,x,n) for(int i=(x);i>=(n);i--)
using namespace std;
const int N=10010;
ll n,maxx,a[N],b[N];
bool st[N];
struct node{
ll c,id;
inline bool operator<(const node &t)const{
return c>t.c;
}
}x[N];
inline ll read(){
ll s=0,f=1;
char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
s=(s<<3)+(s<<1)+(ch^48);
ch=getchar();
}
return s*f;
}
inline void print(ll x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9) print(x/10);
putchar(x%10+'0');
}
inline void Solve(){
n=read();
ll ans=0;
rep(i,1,n) a[i]=read(),ans+=a[i];
rep(i,1,n) b[i]=read(),x[i].c=b[i],x[i].id=i;
stable_sort(x+1,x+n+1);
memset(st,1,sizeof st);
rep(i,1,n){
int id=x[i].id;
ans+=st[id-1]*b[id-1]+st[id+1]*b[id+1];
st[id]=0;
}
print(ans);
}
int main(){
// freopen("A.in","r",stdin);
// freopen("A.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int Tests=1;
while(Tests--) Solve();
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 2ms
memory: 3296kb
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: 3364kb
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: 3468kb
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: 2ms
memory: 3380kb
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: 2ms
memory: 3712kb
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: 4ms
memory: 3652kb
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: 4ms
memory: 3716kb
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: 4ms
memory: 3652kb
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: 4ms
memory: 3808kb
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"