結果

問題 No.2519 Coins in Array
ユーザー ShirotsumeShirotsume
提出日時 2023-09-19 13:45:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 895 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 105,976 KB
最終ジャッジ日時 2023-09-19 13:46:03
合計ジャッジ時間 12,273 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
74,288 KB
testcase_01 AC 124 ms
74,636 KB
testcase_02 AC 125 ms
74,428 KB
testcase_03 WA -
testcase_04 AC 127 ms
74,804 KB
testcase_05 AC 124 ms
74,520 KB
testcase_06 AC 124 ms
74,552 KB
testcase_07 WA -
testcase_08 AC 123 ms
74,312 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 128 ms
74,536 KB
testcase_15 AC 130 ms
74,648 KB
testcase_16 WA -
testcase_17 AC 126 ms
74,784 KB
testcase_18 WA -
testcase_19 AC 126 ms
74,612 KB
testcase_20 AC 127 ms
74,464 KB
testcase_21 AC 128 ms
74,472 KB
testcase_22 AC 123 ms
74,628 KB
testcase_23 AC 265 ms
105,976 KB
testcase_24 AC 258 ms
104,560 KB
testcase_25 AC 130 ms
74,760 KB
testcase_26 AC 126 ms
74,476 KB
testcase_27 AC 257 ms
105,912 KB
testcase_28 AC 256 ms
105,868 KB
testcase_29 AC 265 ms
105,736 KB
testcase_30 AC 244 ms
102,412 KB
testcase_31 AC 161 ms
84,276 KB
testcase_32 AC 195 ms
95,320 KB
testcase_33 AC 226 ms
101,956 KB
testcase_34 AC 187 ms
90,304 KB
testcase_35 AC 215 ms
99,460 KB
testcase_36 AC 174 ms
88,588 KB
testcase_37 AC 162 ms
83,472 KB
testcase_38 AC 201 ms
97,412 KB
testcase_39 AC 180 ms
89,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
import itertools
from math import gcd

def f(x, y):
    if gcd(x, y) == 1:
        return x * y - x - y + 1
    else:
        return 0
n = ii()

a = li()


ans = inf
it = []
if n == 2:
    ans = f(a[0], a[1])
    it = [(1, 2)]
elif n == 3:
    for v in itertools.permutations(a):
        if ans >= f(f(v[0], v[1]), v[2]):
            one = a.index(v[0])
            a[one] = -1
            two = a.index(v[1]) + 1
            a[one] = v[0]
            it = [(one + 1, two + 1), (1, 2)]
            
            ans = min(ans, f(f(v[0], v[1]), v[2]))
else:
    ans = 0
    it = [(1, 2) for _ in range(n - 1)]
print(ans)
for v in it:
    print(*v)


0