Submission #52980476
Source Code Expand
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=200010;
int n,x[2][N],y[2][N];
ll calc(int x[],int sz){
ll res=0,sum=0;
sort(x+1,x+1+sz);
for(ll i=1;i<=sz;++i){
res+=(i-1)*x[i]-sum;
sum+=x[i];
}
return res;
}
int main(){
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#endif
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif
cin>>n;
for(int i=1;i<=n;++i){
int x,y;
cin>>x>>y;
bool t=(x+y)&1;
::x[t][++::x[t][0]]=x+y;
::y[t][++::y[t][0]]=x-y;
}
cout<<((calc(x[0],x[0][0])+calc(x[1],x[1][0])
+calc(y[0],y[0][0])+calc(y[1],y[1][0]))>>1);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Jump Distance Sum |
| User | WUSICHENG |
| Language | C++ 17 (gcc 12.2) |
| Score | 500 |
| Code Size | 673 Byte |
| Status | AC |
| Exec Time | 46 ms |
| Memory | 5196 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3484 KiB |
| example_01.txt | AC | 1 ms | 3428 KiB |
| hand_00.txt | AC | 38 ms | 5052 KiB |
| hand_01.txt | AC | 1 ms | 3488 KiB |
| hand_02.txt | AC | 39 ms | 5048 KiB |
| hand_03.txt | AC | 39 ms | 5044 KiB |
| hand_04.txt | AC | 1 ms | 3412 KiB |
| random_00.txt | AC | 44 ms | 5048 KiB |
| random_01.txt | AC | 44 ms | 5052 KiB |
| random_02.txt | AC | 45 ms | 5060 KiB |
| random_03.txt | AC | 44 ms | 5048 KiB |
| random_04.txt | AC | 45 ms | 4920 KiB |
| random_05.txt | AC | 46 ms | 4988 KiB |
| random_06.txt | AC | 44 ms | 5196 KiB |
| random_07.txt | AC | 45 ms | 4952 KiB |
| random_08.txt | AC | 44 ms | 4988 KiB |
| random_09.txt | AC | 44 ms | 5056 KiB |
| random_10.txt | AC | 45 ms | 5188 KiB |
| random_11.txt | AC | 44 ms | 5056 KiB |
| random_12.txt | AC | 44 ms | 5116 KiB |
| random_13.txt | AC | 44 ms | 4920 KiB |
| random_14.txt | AC | 46 ms | 5112 KiB |
| random_15.txt | AC | 45 ms | 5112 KiB |
| random_16.txt | AC | 46 ms | 5048 KiB |
| random_17.txt | AC | 46 ms | 5048 KiB |
| random_18.txt | AC | 45 ms | 5052 KiB |
| random_19.txt | AC | 45 ms | 4988 KiB |