QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338030#5050. ValueKevin5307RE 7ms3800kbC++23846b2024-02-25 17:03:592024-02-25 17:03:59

Judging History

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

  • [2024-02-25 17:03:59]
  • 评测
  • 测评结果:RE
  • 用时:7ms
  • 内存:3800kb
  • [2024-02-25 17:03:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a[100100],b[100100];
bool flag[100100];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	ll ans=a[1];
	for(int i=2;i<=n;i++)
		if(!flag[i])
		{
			if(i*i>n)
			{
				ans+=a[i];
				continue;
			}
			vector<pair<int,int>> vec;
			for(int j=i,c=1;j<=n;j*=i,c++)
			{
				vec.emplace_back(j,c);
				flag[j]=1;
			}
			ll mx=0;
			int m=vec.size();
			for(int j=0;j<(1<<m);j++)
			{
				ll tot=0;
				for(int k=0;k<m;k++)
					if(j>>k&1)
						tot+=a[vec[k].first];
				for(int k=0;k<m;k++) if(j>>k&1)
					for(int l=k+1;l<m;l++) if(j>>l&1)
						if(vec[l].second%vec[k].second==0)
							tot-=b[vec[l].first];
				mx=max(mx,tot);
			}
			ans+=mx;
		}
	cout<<ans<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3744kb

input:

4
1 1 1 2
1 1 1 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

4
1 1 1 1
1 1 1 2

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

1
4
10

output:

4

result:

ok 1 number(s): "4"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

2
6 8
2 4

output:

14

result:

ok 1 number(s): "14"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

5
1 6 10 5 1
7 1 5 10 9

output:

18

result:

ok 1 number(s): "18"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

10
2 2 8 10 2 10 8 10 6 5
9 2 7 4 2 2 8 3 10 10

output:

55

result:

ok 1 number(s): "55"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

10
8 2 28 71 6 85 90 19 75 99
58 32 12 97 22 54 95 2 22 41

output:

459

result:

ok 1 number(s): "459"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10
499378161 580312139 297991977 488549686 446728905 94747359 449577305 348551824 91900269 509840562
195391767 900284766 199070364 13166132 91649641 462416747 349376583 358291497 486025165 865291797

output:

3353959962

result:

ok 1 number(s): "3353959962"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

100
457992034 292706810 675334392 753902137 68910383 43232856 93369738 421897111 2553628 571090809 308473918 823046294 353799547 596697775 689497551 634976771 180311057 487479264 238310828 773159036 689460373 21840389 460321400 444499701 961273652 170165163 343911050 28242743 466702096 877051765 309...

output:

42242895657

result:

ok 1 number(s): "42242895657"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

100
486342294 640034805 116328197 318162835 39561592 805725108 594609889 653511108 294477518 652922309 577371886 601529202 961360083 316914599 630048249 821394943 617577478 471190718 842113363 185539825 830514090 434572500 858130769 573409395 372400199 154412691 349010381 448381393 329822759 7017456...

output:

49995353551

result:

ok 1 number(s): "49995353551"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

1000
448894631 183123026 397536202 695859698 441207641 802550098 754562453 970029739 793685893 84998873 617823553 939902778 48522348 210952668 110891265 472327126 769948243 504528886 484642894 899868060 873491202 936738789 691583586 408761099 273650760 832514570 933444283 906602631 957885556 2390632...

output:

481253884637

result:

ok 1 number(s): "481253884637"

Test #12:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

1000
431940173 877072106 812881880 498506229 781976778 181162626 821675096 355364102 858897905 78207269 220287853 700799741 950195334 677020604 857218438 11419512 487886146 1351742 541400646 260024939 406623057 401233466 667729667 625068702 976659156 366324562 637947720 775790125 361947488 771049914...

output:

503564405157

result:

ok 1 number(s): "503564405157"

Test #13:

score: 0
Accepted
time: 7ms
memory: 3656kb

input:

10000
897180145 639024783 297814345 599347347 335699724 653902766 731457122 359537664 890880519 961735566 974069309 600480085 710274564 529416610 556671369 459228576 203765211 505991218 781364708 773174786 927669398 887443162 413959780 361539122 351822835 484024073 127009297 276696312 626246885 3275...

output:

4950387399123

result:

ok 1 number(s): "4950387399123"

Test #14:

score: 0
Accepted
time: 7ms
memory: 3664kb

input:

10000
99283948 80018588 157042338 275031260 803224680 155142917 963071119 651461554 267679314 525600830 607328025 208040621 285267196 469967308 892832645 336686486 627668154 549985240 338969689 63971608 340401509 990285235 837836769 772665669 895878875 343899212 692372139 549882383 450940796 7617906...

output:

4958574994437

result:

ok 1 number(s): "4958574994437"

Test #15:

score: -100
Runtime Error

input:

100000
746411323 844734199 828701336 498763883 140622415 41748996 283525015 150874283 490856305 794774154 978830637 62220090 406108977 945064992 966918653 799999763 458956649 476010818 399933489 893718613 902605235 148991441 992417782 665098944 232865262 895486864 349693949 721517627 933206717 63472...

output:


result: