結果

問題 No.2519 Coins in Array
ユーザー vwxyzvwxyz
提出日時 2023-11-29 18:33:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 34,500 KB
最終ジャッジ日時 2023-11-29 18:33:41
合計ジャッジ時間 11,035 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
11,136 KB
testcase_01 AC 37 ms
11,136 KB
testcase_02 AC 37 ms
11,136 KB
testcase_03 AC 37 ms
11,136 KB
testcase_04 WA -
testcase_05 AC 38 ms
11,136 KB
testcase_06 AC 40 ms
11,136 KB
testcase_07 AC 39 ms
11,136 KB
testcase_08 AC 38 ms
11,136 KB
testcase_09 AC 38 ms
11,136 KB
testcase_10 AC 38 ms
11,136 KB
testcase_11 AC 37 ms
11,136 KB
testcase_12 AC 38 ms
11,136 KB
testcase_13 AC 40 ms
11,136 KB
testcase_14 AC 38 ms
11,136 KB
testcase_15 AC 37 ms
11,136 KB
testcase_16 AC 37 ms
11,136 KB
testcase_17 AC 38 ms
11,136 KB
testcase_18 AC 37 ms
11,136 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 37 ms
11,136 KB
testcase_23 AC 389 ms
34,500 KB
testcase_24 AC 358 ms
33,864 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 387 ms
34,500 KB
testcase_28 AC 358 ms
34,500 KB
testcase_29 AC 368 ms
34,500 KB
testcase_30 AC 328 ms
31,640 KB
testcase_31 AC 87 ms
14,832 KB
testcase_32 AC 190 ms
21,716 KB
testcase_33 AC 262 ms
28,060 KB
testcase_34 AC 144 ms
18,788 KB
testcase_35 AC 242 ms
25,928 KB
testcase_36 AC 123 ms
17,168 KB
testcase_37 AC 97 ms
13,944 KB
testcase_38 AC 211 ms
23,496 KB
testcase_39 AC 132 ms
18,092 KB
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

N=int(readline())
A=list(map(int,readline().split()))
def f(a,b):
    if GCD(a,b)>1:
        return 0
    return (a-1)*(b-1)
ans_lst=[]
if N>=4:
    ans=0
    idx0=[i for i in range(N) if A[i]%2==0]
    while len(idx0)<2:
        idx1=[i for i in range(N) if A[i]%2]
        ans_lst.append(idx1[0],idx1[1])
        A=[A[i] for i in range(N) if not i in idx1[:2]]+[(A[idx1[0]]-1)*(A[idx1[1]]-1)]
        N-=1
    ans_lst.append((idx0[0],idx0[1]))
    for i in range(N-2):
        ans_lst.append((0,1))
elif N==3:
    ans=1<<60
    ans_lst=None
    for i,j,k in ((0,1,2),(0,2,1),(1,2,0)):
        a=f(f(A[i],A[j]),A[k])
        if a<ans:
            ans=a
            ans_lst=[(i,j),(0,1)]
elif N==2:
    ans=f(A[0],A[1])
    ans_lst=[(0,1)]
print(ans)
for i,j in ans_lst:
    print(i+1,j+1)
0