Submission #56620096
Source Code Expand
// LUOGU_RID: 172112502
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5,M=2e6;
bool __ST__;
int n,D;
int X[N],Y[N];
int Ax[M*2+10],By[M*2+10];
int sx[N],sy[N];
bool __ED__;
int SX(int l,int r)
{
if(l>r) return 0;
return sx[r]-sx[l-1];
}
int SY(int l,int r)
{
if(l>r) return 0;
return sy[r]-sy[l-1];
}
signed main()
{
cerr<<abs(&__ED__-&__ST__)/(1024.0*1024.0)<<" MiB\n";
scanf("%lld%lld",&n,&D);
for(int i=1;i<=n;i++)
scanf("%lld%lld",&X[i],&Y[i]),X[i]+=M,Y[i]+=M;
sort(X+1,X+n+1);
sort(Y+1,Y+n+1);
for(int i=1;i<=n;i++)
sx[i]=sx[i-1]+X[i],sy[i]=sy[i-1]+Y[i];
int Px=1,Py=1;
for(int i=0;i<=M+M;i++)
{
while(i==X[Px]) Px++;
Ax[i]=SX(Px,n)-SX(1,Px-1)+(2*Px-n-2)*i;
while(i==Y[Py]) Py++;
By[i]=SY(Py,n)-SY(1,Py-1)+(2*Py-n-2)*i;
}
sort(By,By+M+M+1);
int ans=0;
for(int i=0;i<=M+M;i++)
{
int it=upper_bound(By,By+M+M+1,D-Ax[i])-By;
ans+=it;
}
printf("%lld\n",ans);
return 0;
}
// Lose the illusions and prepare to fight.
Submission Info
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%lld%lld",&n,&D);
| ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%lld%lld",&X[i],&Y[i]),X[i]+=M,Y[i]+=M;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
475 / 475 |
| Status |
|
|
| 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 |
399 ms |
66136 KiB |
| 00_sample_02.txt |
AC |
399 ms |
66128 KiB |
| 00_sample_03.txt |
AC |
398 ms |
66364 KiB |
| 01_random_01.txt |
AC |
420 ms |
66220 KiB |
| 01_random_02.txt |
AC |
401 ms |
66212 KiB |
| 01_random_03.txt |
AC |
414 ms |
66352 KiB |
| 01_random_04.txt |
AC |
401 ms |
66424 KiB |
| 01_random_05.txt |
AC |
384 ms |
66356 KiB |
| 01_random_06.txt |
AC |
414 ms |
72356 KiB |
| 01_random_07.txt |
AC |
409 ms |
72424 KiB |
| 01_random_08.txt |
AC |
393 ms |
66216 KiB |
| 01_random_09.txt |
AC |
402 ms |
66388 KiB |
| 01_random_10.txt |
AC |
392 ms |
66288 KiB |
| 01_random_11.txt |
AC |
402 ms |
66364 KiB |
| 01_random_12.txt |
AC |
407 ms |
66216 KiB |
| 01_random_13.txt |
AC |
399 ms |
66280 KiB |
| 01_random_14.txt |
AC |
399 ms |
66376 KiB |
| 01_random_15.txt |
AC |
394 ms |
66232 KiB |
| 01_random_16.txt |
AC |
408 ms |
66144 KiB |
| 01_random_17.txt |
AC |
395 ms |
66316 KiB |
| 01_random_18.txt |
AC |
393 ms |
66372 KiB |
| 01_random_19.txt |
AC |
392 ms |
66180 KiB |
| 01_random_20.txt |
AC |
393 ms |
66352 KiB |
| 02_handmade_01.txt |
AC |
404 ms |
66156 KiB |
| 02_handmade_02.txt |
AC |
327 ms |
66392 KiB |
| 02_handmade_03.txt |
AC |
334 ms |
66276 KiB |
| 02_handmade_04.txt |
AC |
334 ms |
66360 KiB |
| 02_handmade_05.txt |
AC |
327 ms |
66224 KiB |
| 02_handmade_06.txt |
AC |
324 ms |
66188 KiB |