QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#822167#9902. 求和suyueovo100 ✓61ms6020kbC++23632b2024-12-19 23:05:512024-12-19 23:05:51

Judging History

你现在查看的是最新测评结果

  • [2024-12-19 23:05:51]
  • 评测
  • 测评结果:100
  • 用时:61ms
  • 内存:6020kb
  • [2024-12-19 23:05:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100005];
int b[100005];
int cal(int c[])
{
	int p[n+1];
	for(int i=1;i<=n;i++)
	{
		p[i]=c[i];
	}
	sort(p+1,p+1+n);
	int sum=0;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		sum+=p[i];
		ans+=i*p[i]-sum;
	}
	return ans*2;
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	int ans=0;
	ans+=cal(a);
	ans+=cal(b);
	for(int i=1;i<=n;i++)
	{
		int x=a[i];
		int y=b[i];
		a[i]=x+y;
		b[i]=x-y;
	}
	ans-=cal(a)/2;
	ans-=cal(b)/2;
	cout<<ans;
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 1ms
memory: 3656kb

input:

1000
6858 7266 2204 9448 3411 7466 8694 7815 7932 1414 4877 2123 4249 3992 5960 1527 99 2214 3634 5475 4614 6728 5928 9113 3121 5164 3212 3960 202 5875 3589 1125 8968 6641 1261 8549 6503 4544 6034 4101 1047 3726 2453 4578 8573 7802 5950 9057 209 4059 9286 328 7919 9833 3467 9443 1590 354 6607 7568 2...

output:

1983241576

result:

ok 1 number(s): "1983241576"

Test #2:

score: 10
Accepted
time: 1ms
memory: 3628kb

input:

1000
514483 623943 95786 5162 480063 469510 40617 147410 457621 203184 153117 682815 995705 146286 86645 91921 294948 993207 209940 442107 987138 90138 482128 7494 520629 982073 115316 173004 797328 449480 273534 388733 718556 216466 373217 648349 586070 718644 901125 66372 915183 62752 91266 203293...

output:

197768260412

result:

ok 1 number(s): "197768260412"

Test #3:

score: 10
Accepted
time: 1ms
memory: 3632kb

input:

1000
597907 140084 876340 667344 796613 139774 845304 331398 391777 540071 380853 209855 828499 748527 56968 572542 766862 497661 640662 739052 83591 237916 622341 849173 834486 324985 209537 565161 254744 716646 16952 642107 60847 159899 175326 242949 453504 916015 488362 823778 98580 456675 289751...

output:

200454518772

result:

ok 1 number(s): "200454518772"

Test #4:

score: 10
Accepted
time: 33ms
memory: 6020kb

input:

100000
39 41 6 41 37 4 3 31 11 23 12 45 15 5 34 41 43 20 25 34 21 30 32 8 3 16 29 11 49 17 9 33 19 42 44 24 41 29 44 44 4 12 18 37 7 50 3 20 6 40 30 31 32 47 32 29 45 48 1 49 48 38 26 27 9 31 32 45 27 24 25 43 14 11 17 7 23 9 49 46 47 27 40 28 8 4 38 46 28 13 22 19 31 31 44 13 2 3 46 34 20 19 42 20 ...

output:

99779331604

result:

ok 1 number(s): "99779331604"

Test #5:

score: 10
Accepted
time: 33ms
memory: 5884kb

input:

100000
18 35 5 18 36 23 33 15 16 5 6 43 9 46 49 8 23 33 44 24 24 8 42 41 14 29 42 22 12 38 36 7 14 28 6 24 21 46 32 1 47 23 49 46 4 33 19 10 28 48 40 36 18 21 28 13 36 19 10 3 13 47 11 1 41 39 17 22 26 12 20 29 29 19 43 38 29 46 44 4 1 29 20 2 1 25 14 43 28 36 10 35 38 46 4 49 10 50 38 4 43 43 47 15...

output:

100001868666

result:

ok 1 number(s): "100001868666"

Test #6:

score: 10
Accepted
time: 53ms
memory: 5956kb

input:

100000
527194 477800 752839 180167 191874 389516 36225 830569 268550 174287 567002 62920 413688 164227 609932 825264 260957 338574 240390 666689 97260 424232 802475 425711 539346 265633 753489 222400 391024 841304 417667 626065 777244 665797 529408 865362 195996 120688 528569 405445 252590 98423 304...

output:

3328288024082832

result:

ok 1 number(s): "3328288024082832"

Test #7:

score: 10
Accepted
time: 52ms
memory: 5960kb

input:

100000
935271 64094 419766 967410 987200 672980 992196 981416 474184 738909 354481 198562 816020 928280 252364 745096 13133 241046 711161 803190 308786 455327 784368 613951 196115 637358 496763 361573 148311 660401 447164 478627 62967 444042 926116 70500 260801 938000 905917 378952 86806 690831 3709...

output:

3336745272733726

result:

ok 1 number(s): "3336745272733726"

Test #8:

score: 10
Accepted
time: 57ms
memory: 5924kb

input:

100000
451411 844648 49244 316664 498681 636452 176184 915572 811070 999349 946929 998652 609749 931307 700281 992818 484884 639064 8106 91131 232372 562837 658751 927808 506323 764283 954328 75886 448181 403819 765946 596726 6399 246151 329229 905229 490876 525238 406428 819245 448024 856612 571544...

output:

3338427607942440

result:

ok 1 number(s): "3338427607942440"

Test #9:

score: 10
Accepted
time: 61ms
memory: 6020kb

input:

100000
945922 870287 139920 474749 874211 112088 630085 399075 696722 834935 812682 466419 626600 487984 598259 925625 340435 783993 396774 342902 11860 775614 370080 659039 446337 949595 92401 976732 334788 493541 550267 296394 137241 576226 912439 357626 807892 970443 105584 312431 401817 791505 3...

output:

1998848192031322

result:

ok 1 number(s): "1998848192031322"

Test #10:

score: 10
Accepted
time: 57ms
memory: 5936kb

input:

100000
996642 419131 144666 328419 966569 590864 626261 583063 630878 139117 73122 26162 393986 281713 535878 373542 845053 288448 827496 382951 75609 923391 477590 533422 792898 292508 186622 434297 16396 728003 69493 582472 512237 486954 747252 728034 642622 200518 692821 102542 874814 185428 3708...

output:

2001013327678236

result:

ok 1 number(s): "2001013327678236"

Extra Test:

score: 0
Extra Test Passed