标签:struct class 工作 char val ++ 答案 记录 pre
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
inline int read(){
int x=0,o=1;char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')o=-1,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*o;
}
const int N=1e5+5;
int sum[N],far[N],g[N];
struct ppx{int dis,val;}a[N];
inline bool cmp(ppx x,ppx y){return x.val>y.val;}
int main(){
int n=read();
for(int i=1;i<=n;++i)a[i].dis=read();
for(int i=1;i<=n;++i)a[i].val=read();
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;++i)sum[i]=sum[i-1]+a[i].val;
for(int i=1;i<=n;++i)far[i]=max(far[i-1],a[i].dis);
for(int i=n;i>=1;--i)g[i]=max(g[i+1],2*a[i].dis+a[i].val);
for(int i=1;i<=n;++i)printf("%d\n",max(2*far[i]+sum[i],sum[i-1]+g[i]));
return 0;
}
标签:struct class 工作 char val ++ 答案 记录 pre
原文地址:https://www.cnblogs.com/PPXppx/p/11623372.html