Submission #56575494


Source Code Expand

#include<bits/stdc++.h>
#define lc(p) ((p)*2)
#define rc(p) ((p)*2+1)
#define mkpr make_pair
#define LL long long
using namespace std;
inline LL read() {
    char ch=getchar();
    LL x=0;
    bool t=0;
    while(ch<'0'||ch>'9')   t|=ch=='-',ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return t?-x:x;
}
int n,d,a[200005],b[200005];
LL x[4000006],y[4000006];
LL ans,s[200005];
const int N=2000000;
int main(){
	n=read();
	d=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		b[i]=read();
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];
	}
	for(int i=-N;i<=N;i++){
		int pos=lower_bound(a+1,a+1+n,i)-a;
		x[i+N]=s[n]-s[pos-1]-1ll*(n-pos+1)*i+1ll*(pos-1)*i-s[pos-1];
	}
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+b[i];
	}
	for(int i=-N;i<=N;i++){
		int pos=lower_bound(b+1,b+1+n,i)-b;
		y[i+N]=s[n]-s[pos-1]-1ll*(n-pos+1)*i+1ll*(pos-1)*i-s[pos-1];
	}
	sort(x,x+1+N*2);
	for(int i=-N;i<=N;i++){
		int pos=upper_bound(x,x+1+N*2,d-y[i+N])-x;
		ans+=pos;
	}
	cout<<ans;
	return 0;
}

Submission Info

Submission Time
Task E - Manhattan Multifocal Ellipse
User cpz0342
Language C++ 20 (gcc 12.2)
Score 475
Code Size 1084 Byte
Status AC
Exec Time 538 ms
Memory 69120 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 408 ms 65968 KiB
00_sample_02.txt AC 405 ms 65992 KiB
00_sample_03.txt AC 414 ms 66000 KiB
01_random_01.txt AC 419 ms 66036 KiB
01_random_02.txt AC 413 ms 66132 KiB
01_random_03.txt AC 412 ms 66128 KiB
01_random_04.txt AC 405 ms 65972 KiB
01_random_05.txt AC 412 ms 66012 KiB
01_random_06.txt AC 520 ms 69120 KiB
01_random_07.txt AC 538 ms 69052 KiB
01_random_08.txt AC 440 ms 66136 KiB
01_random_09.txt AC 450 ms 66164 KiB
01_random_10.txt AC 446 ms 66064 KiB
01_random_11.txt AC 443 ms 66012 KiB
01_random_12.txt AC 446 ms 66080 KiB
01_random_13.txt AC 432 ms 66052 KiB
01_random_14.txt AC 459 ms 66080 KiB
01_random_15.txt AC 456 ms 66208 KiB
01_random_16.txt AC 451 ms 66012 KiB
01_random_17.txt AC 448 ms 65976 KiB
01_random_18.txt AC 447 ms 65976 KiB
01_random_19.txt AC 453 ms 66068 KiB
01_random_20.txt AC 459 ms 66064 KiB
02_handmade_01.txt AC 398 ms 66008 KiB
02_handmade_02.txt AC 450 ms 66024 KiB
02_handmade_03.txt AC 328 ms 66060 KiB
02_handmade_04.txt AC 324 ms 65972 KiB
02_handmade_05.txt AC 328 ms 66060 KiB
02_handmade_06.txt AC 323 ms 65948 KiB