結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
74,712 KB
testcase_01 AC 127 ms
74,540 KB
testcase_02 AC 112 ms
74,608 KB
testcase_03 WA -
testcase_04 AC 112 ms
74,544 KB
testcase_05 AC 114 ms
74,772 KB
testcase_06 AC 115 ms
74,704 KB
testcase_07 WA -
testcase_08 AC 113 ms
74,328 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 113 ms
74,488 KB
testcase_15 AC 117 ms
74,712 KB
testcase_16 WA -
testcase_17 AC 113 ms
74,440 KB
testcase_18 WA -
testcase_19 AC 114 ms
74,288 KB
testcase_20 AC 119 ms
74,556 KB
testcase_21 AC 117 ms
74,612 KB
testcase_22 AC 113 ms
74,280 KB
testcase_23 AC 271 ms
105,916 KB
testcase_24 AC 251 ms
104,732 KB
testcase_25 AC 114 ms
74,620 KB
testcase_26 AC 113 ms
74,680 KB
testcase_27 AC 244 ms
105,760 KB
testcase_28 AC 267 ms
105,960 KB
testcase_29 AC 242 ms
105,856 KB
testcase_30 AC 230 ms
102,208 KB
testcase_31 AC 166 ms
84,356 KB
testcase_32 AC 189 ms
95,508 KB
testcase_33 AC 210 ms
101,788 KB
testcase_34 AC 168 ms
90,156 KB
testcase_35 AC 217 ms
99,480 KB
testcase_36 AC 161 ms
88,224 KB
testcase_37 AC 152 ms
83,540 KB
testcase_38 AC 191 ms
96,848 KB
testcase_39 AC 169 ms
89,700 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.remove(v[0])
            two = a.index(v[1]) + 1
            a.insert(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