結果

問題 No.2519 Coins in Array
ユーザー ShirotsumeShirotsume
提出日時 2023-09-19 13:44:44
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 852 bytes
コンパイル時間 3,857 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 106,052 KB
最終ジャッジ日時 2023-09-19 13:45:08
合計ジャッジ時間 12,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
74,504 KB
testcase_01 AC 107 ms
74,504 KB
testcase_02 AC 118 ms
74,440 KB
testcase_03 RE -
testcase_04 AC 115 ms
74,928 KB
testcase_05 AC 106 ms
75,012 KB
testcase_06 AC 109 ms
74,612 KB
testcase_07 RE -
testcase_08 AC 109 ms
74,576 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 109 ms
74,500 KB
testcase_15 AC 107 ms
74,696 KB
testcase_16 RE -
testcase_17 AC 111 ms
74,316 KB
testcase_18 RE -
testcase_19 AC 106 ms
74,588 KB
testcase_20 AC 110 ms
74,316 KB
testcase_21 AC 107 ms
74,516 KB
testcase_22 AC 108 ms
74,396 KB
testcase_23 AC 245 ms
106,052 KB
testcase_24 AC 243 ms
105,012 KB
testcase_25 AC 107 ms
74,500 KB
testcase_26 AC 106 ms
74,904 KB
testcase_27 AC 228 ms
106,052 KB
testcase_28 AC 233 ms
105,900 KB
testcase_29 AC 228 ms
105,760 KB
testcase_30 AC 218 ms
102,580 KB
testcase_31 AC 141 ms
84,584 KB
testcase_32 AC 182 ms
95,532 KB
testcase_33 AC 199 ms
102,312 KB
testcase_34 AC 161 ms
90,232 KB
testcase_35 AC 187 ms
99,488 KB
testcase_36 AC 155 ms
88,248 KB
testcase_37 AC 145 ms
83,704 KB
testcase_38 AC 178 ms
96,928 KB
testcase_39 AC 156 ms
89,352 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])
            two = a.index(v[1], one+1) + 1
            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