Logo
(追記) (追記ここまで)

23463번 - Value 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB954100.000%

문제

Pang believes that one cannot make an omelet without breaking eggs.

For a subset $A$ of $\{1,2,\ldots,n\},ドル we calculate the score of $A$ as follows:

  1. Initialize the score as 0ドル$.
  2. For any $i\in A,ドル add $a_i$ to the score.
  3. For any pair of integers $(i, j)$ satisfying $i\ge 2,ドル $j\ge 2,ドル $i\in A$ and $j\in A,ドル if there exists positive integer $k > 1$ such that $i^k=j,ドル subtract $b_j$ from the score.

Find the maximum possible score over the choice of $A$.

입력

The first line contains a single integer $n$ $(1\le n\le 100000)$.

The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ $(1\le a_i\le 1000000000)$.

The third line contains $n$ integers $b_1,b_2,\ldots,b_n$ $(1\le b_i\le 1000000000)$.

출력

Print a single integer $x$ --- the maximum possible score.

제한

예제 입력 1

4
1 1 1 2
1 1 1 1

예제 출력 1

4

예제 입력 2

4
1 1 1 1
1 1 1 2

예제 출력 2

3

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 10: Grand Prix of Xi’An M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /