ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183155 | #3288. 恐狼前锋 | Richard1211 | 100 | 25ms | 3876kb | C++11 | 7.2kb | 2023-08-08 09:37:59 | 2023-08-08 12:33:37 |
answer
//#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
//#include <bits/extc++.h>
#else
//#include <ext/rope>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#endif
using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
const double pi=3.141592653589793238462643383279;
template<class T>inline T Min(register T a,register T b){
return a<b?a:b;
}
template<class T>inline T Max(register T a,register T b){
return a>b?a:b;
}
template<class T>inline bool Cmin(register T &a,register T b){
return a>b?(a=b,true):false;
}
template<class T>inline bool Cmax(register T &a,register T b){
return a<b?(a=b,true):false;
}
template<class T>inline T Abs(register T a){
return a>0?a:-a;
}
template<class T>inline T Lowbit(register T x){
return (x)&(-x);
}
template<class T>inline void Swap(register T &a,register T &b){
b^=a^=b^=a;
}
template<class T>inline T Gcd(T a,T b){
return b?Gcd(b,a%b):a;
}
template<class T>inline T Lcm(T a,T b){
return a*b/Gcd(a,b);
}
template<class T>inline T Exgcd(T a,T b,T &x,T &y){
if(b==0){
x=1;
y=0;
return a;
}
T d=Exgcd(b,a%b,x,y);
T t=x;
x=y;
y=t-a/b*y;
return d;
}
template<class T>inline T ExExgcd(T a,T b,T &x,T &y,T c){
if(b==0){
x=c;
y=0;
return a;
}
T d=ExExgcd(b,a%b,x,y,c);
T t=x;
x=y;
y=t-a/b*y;
return d;
}
template<class T>inline T Ksc(T a,T b){
if(a==0||b==0){
return 0;
}
T ans=0;
while(b){
if(b&1){
ans=a+ans;
}
a=a+a;
b>>=1;
}
return ans;
}
template<class T>inline T Ksc(T a,T b,T p){
if(a==0||b==0){
return 0;
}
T ans=0;
while(b){
if(b&1){
ans=(a+ans)%p;
}
a=(a+a)%p;
b>>=1;
}
return ans;
}
template<class T>inline T Ksm(T a,T b,bool f=false){
if(a==0){
return 0;
}
if(b==0){
return 1;
}
T ans=1;
while(b){
if(b&1){
ans=!f?a*ans:Ksc(a,ans);
}
a=!f?a*a:Ksc(a,a);
b>>=1;
}
return ans;
}
template<class T>inline T Ksm(T a,T b,T p,bool f=false){
if(a==0){
return 0;
}
if(b==0){
return 1%p;
}
T ans=1;
while(b){
if(b&1){
ans=!f?a*ans%p:Ksc(a,ans,p);
}
a=!f?a*a%p:Ksc(a,a,p);
b>>=1;
}
return ans;
}
template<class T>inline T Inv(T x,T p){
return Ksm(x,p-2,p);
}
template<class T>inline T Fac(T n){
if(n==0){
return 1;
}
long long ans=1;
for(long long i=1;i<=n;i++){
ans*=i;
}
return ans;
}
template<class T>inline T Fac(T n,T p){
if(n==0){
return 1;
}
long long ans=1;
for(long long i=1;i<=n;i++){
ans=ans*i%p;
}
return ans;
}
template<class T>inline long long Onenum(T x,bool f=true){
return f?__builtin_popcountll(x):__builtin_popcount(x);
}
template<class T>inline long long Lowone(T x,bool f=true){
return f?__builtin_ffsll(x):__builtin_ffs(x);
}
template<class T>inline long long Oneoddeven(T x,bool f=true){
return f?__builtin_parityll(x):__builtin_parity(x);
}
template<class T>inline long long Prezero(T x,bool f=true){
return f?__builtin_clzll(x):__builtin_clz(x);
}
template<class T>inline long long Sufzero(T x,bool f=true){
return f?__builtin_ctzll(x):__builtin_ctz(x);
}
template<class T>inline bool Isdigit(T ch){
return ch>='0' && ch<='9';
}
template<class T>inline bool Isletter(T ch){
return ch>='A' && ch<='Z' || ch>='a' && ch<='z';
}
template<class T>inline void Memset(T *d,long long n,long long s){
for(long long i=0;i<=s-1;i++){
d[i]=n;
}
}
template<class T>inline void debug(T s,string name){
cout << name << ": " << s << endl;
}
template<class T>inline void bug(T s){
cout << s << endl;
}
template<class T>inline T Sin(register T degree){
return sin(degree*(pi/180));
}
template<class T>inline T Cos(register T degree){
return cos(degree*(pi/180));
}
template<class T>inline T Tan(register T degree){
return tan(degree*(pi/180));
}
template<class T>inline T Asin(register T degree){
return asin(degree*(pi/180));
}
template<class T>inline T Acos(register T degree){
return acos(degree*(pi/180));
}
template<class T>inline T Atan(register T degree){
return atan(degree*(pi/180));
}
inline int rd(){
int x=0,f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*f;
}
inline long long read(){
long long x=0,f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*f;
}
inline unsigned long long Read(){
unsigned long long x=0;
long long f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*f;
}
inline bool wrt(int x,char ch='\n'){
static char buf[64];
static int len=-1;
if(x<0){
putchar('-');
x=-x;
}
do{
buf[++len]=x%10;
x/=10;
}
while(x);
while(len>=0){
putchar(buf[len--]+'0');
}
putchar(ch);
return true;
}
inline bool write(long long x,char ch='\n'){
static char buf[64];
static long long len=-1;
if(x<0){
putchar('-');
x=-x;
}
do{
buf[++len]=x%10;
x/=10;
}
while(x);
while(len>=0){
putchar(buf[len--]+'0');
}
putchar(ch);
return true;
}
inline bool Write(unsigned long long x,char ch='\n'){
static char buf[64];
static long long len=-1;
if(x<0){
putchar('-');
x=-x;
}
do{
buf[++len]=x%10;
x/=10;
}
while(x);
while(len>=0){
putchar(buf[len--]+'0');
}
putchar(ch);
return true;
}
inline void OF(string s){
string IN=s+".in";
string OUT=s+".out";
freopen(IN.c_str(),"r",stdin);
freopen(OUT.c_str(),"w",stdout);
}
inline void CF(string s){
fclose(stdin);
fclose(stdout);
}
const long long N=100100;
struct Query{
long long a,b,id;
};
long long n,ans;
long long a[N],b[N];
bool vis[N];
Query q[N];
int main(){
n=read();
for(register int i=1;i<=n;++i){
a[i]=read();
q[i].a=a[i];
}
for(register int i=1;i<=n;++i){
b[i]=read();
q[i].b=b[i];
}
for(register int i=1;i<=n;++i){
q[i].id=i;
}
sort(q+1,q+n+1,[&](Query x,Query y){return x.b>y.b;});
vis[0]=true;
vis[n+1]=true;
for(register int i=1;i<=n;++i){
ans+=q[i].a;
ans+=vis[q[i].id-1]?0:b[q[i].id-1];
ans+=vis[q[i].id+1]?0:b[q[i].id+1];
vis[q[i].id]=true;
}
return !write(ans);
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 2ms
memory: 3324kb
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: 3360kb
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: 2ms
memory: 3440kb
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: 3320kb
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: 3360kb
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: 3848kb
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: 2ms
memory: 3836kb
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: 2ms
memory: 3588kb
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: 3ms
memory: 3800kb
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: 3876kb
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"