QOJ.ac
QOJ
QOJ is currently under a maintenance. It might be unavailable in the following a few hours.
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#1574 | #839268 | #9902. 求和 | lfxxx | Hanghang | Failed. | 2025-02-24 20:03:27 | 2025-02-24 20:03:27 |
詳細信息
Extra Test:
Invalid Input
input:
2341232131312312312312313
output:
result:
FAIL Expected integer, but "2341232131312312312312313" found (stdin, line 1)
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#839268 | #9902. 求和 | Hanghang# | 100 ✓ | 62ms | 14660kb | C++17 | 441b | 2025-01-01 15:56:16 | 2025-01-01 15:56:17 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+3;
ll n,ax[N],ay[N],bx[N],by[N];
ll Sol(ll *d)
{
sort(d+1,d+n+1);ll s=0;
for(int i=1;i<=n;i++)s+=d[i]*(i-1-n+i);
return s;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>ax[i];
for(int i=1;i<=n;i++)cin>>ay[i];
for(int i=1;i<=n;i++)bx[i]=ax[i]+ay[i],by[i]=ax[i]-ay[i];
ll s1=Sol(ax)+Sol(ay),s2=Sol(bx)+Sol(by);
cout<<2*s1-s2;
}