結果

問題 No.2519 Coins in Array
ユーザー ニックネームニックネーム
提出日時 2023-10-27 22:47:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 33,044 KB
最終ジャッジ日時 2023-10-27 22:47:56
合計ジャッジ時間 8,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,272 KB
testcase_01 AC 30 ms
10,272 KB
testcase_02 AC 30 ms
10,272 KB
testcase_03 AC 30 ms
10,272 KB
testcase_04 WA -
testcase_05 AC 29 ms
10,272 KB
testcase_06 AC 29 ms
10,272 KB
testcase_07 WA -
testcase_08 AC 30 ms
10,272 KB
testcase_09 AC 30 ms
10,272 KB
testcase_10 AC 30 ms
10,272 KB
testcase_11 AC 30 ms
10,272 KB
testcase_12 AC 30 ms
10,272 KB
testcase_13 WA -
testcase_14 AC 29 ms
10,272 KB
testcase_15 AC 29 ms
10,272 KB
testcase_16 WA -
testcase_17 AC 32 ms
10,272 KB
testcase_18 AC 30 ms
10,272 KB
testcase_19 AC 30 ms
10,272 KB
testcase_20 AC 30 ms
10,272 KB
testcase_21 AC 29 ms
10,272 KB
testcase_22 AC 30 ms
10,272 KB
testcase_23 AC 359 ms
32,012 KB
testcase_24 AC 359 ms
33,044 KB
testcase_25 AC 30 ms
10,272 KB
testcase_26 AC 30 ms
10,272 KB
testcase_27 AC 357 ms
32,012 KB
testcase_28 AC 355 ms
32,012 KB
testcase_29 AC 357 ms
32,012 KB
testcase_30 AC 332 ms
31,200 KB
testcase_31 AC 84 ms
13,996 KB
testcase_32 AC 190 ms
21,284 KB
testcase_33 AC 259 ms
25,356 KB
testcase_34 AC 137 ms
17,244 KB
testcase_35 AC 240 ms
24,968 KB
testcase_36 AC 115 ms
16,200 KB
testcase_37 AC 67 ms
12,940 KB
testcase_38 AC 205 ms
22,428 KB
testcase_39 AC 128 ms
16,976 KB
testcase_40 AC 329 ms
19,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
n = int(input())
a = list(map(int,input().split()))
def f(x,y): return 0 if gcd(x,y)>1 else x*y-x-y+1
if n==2: print(f(a[0],a[1])); print(1,2)
elif n==3:
    p,q,r = f(f(a[0],a[1]),a[2]),f(f(a[1],a[2]),a[0]),f(f(a[2],a[0]),a[1])
    if q>=p<=r: print(p); print(1,2); print(1,2)
    elif q<=r: print(q); print(2.3); print(1,2)
    else: print(r); print(3,1); print(1,2)
else:
    print(0); j = [[],[],[]]
    for i,v in enumerate(a): j[v%3].append(i)
    if len(j[0])==0: print(1,2); print(1,2)
    elif len(j[0])>=2: print(j[0][0]+1,j[0][1]+1); print(1,n-1)
    elif len(j[2])>=2: print(j[2][0]+1,j[2][1]+1); print(j[0][0]+1,n-1)
    else: print(j[0][0]+1,j[0][1]+1); print(1,2)
    for i in range(n-2,1,-1): print(1,i)
0