이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int N=5e5+5,M=1e9+7;
int a[N],n,b[N],p[N],c[2*N];
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
p[0]=1;
for (int i=1;i<N;i++) p[i]=p[i-1]*2%M;
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i],c[i]=a[i];
for (int i=1;i<=n;i++) cin>>b[i],c[i+n]=b[i];
sort(c+1,c+1+2*n);
int ans=0;
for (int i=1;i<=n;i++){
for (int j=1;j<=2*n;j++){
if (c[j]==c[j-1]) continue;
int l=1,r=1;
for (int k=1;k<i;k++){
int x=(a[k]<c[j])+(b[k]<c[j]);
l=l*x%M;
}
l=(p[i-1]-l+M)%M;
for (int k=i+1;k<=n;k++){
int x=(a[k]<c[j])+(b[k]<c[j]);
r=r*x%M;
}
r=(p[n-i]-r+M)%M;
//cout<<i<<' '<<c[j]<<' '<<l<<' '<<r<<endl;
l=l*r%M;
if (a[i]<c[j]) ans=(ans+(l*(c[j]-c[j-1])%M))%M;
if (b[i]<c[j]) ans=(ans+(l*(c[j]-c[j-1])%M))%M;
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |