結果
問題 | No.2746 Bicolor Pyramid |
ユーザー | shobonvip |
提出日時 | 2024-04-21 06:57:57 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 1,358 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 63,312 KB |
最終ジャッジ日時 | 2024-10-13 05:41:59 |
合計ジャッジ時間 | 4,113 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
57,532 KB |
testcase_01 | AC | 49 ms
57,804 KB |
testcase_02 | AC | 51 ms
62,236 KB |
testcase_03 | AC | 46 ms
57,992 KB |
testcase_04 | AC | 46 ms
57,872 KB |
testcase_05 | AC | 50 ms
60,512 KB |
testcase_06 | AC | 54 ms
63,312 KB |
testcase_07 | AC | 45 ms
57,532 KB |
testcase_08 | AC | 45 ms
57,596 KB |
testcase_09 | AC | 104 ms
58,744 KB |
testcase_10 | AC | 116 ms
57,392 KB |
testcase_11 | AC | 93 ms
57,308 KB |
testcase_12 | AC | 108 ms
57,932 KB |
testcase_13 | AC | 114 ms
58,636 KB |
testcase_14 | AC | 46 ms
57,580 KB |
testcase_15 | AC | 124 ms
58,148 KB |
testcase_16 | AC | 63 ms
59,916 KB |
testcase_17 | AC | 75 ms
58,996 KB |
testcase_18 | AC | 77 ms
57,548 KB |
testcase_19 | AC | 61 ms
58,264 KB |
testcase_20 | AC | 63 ms
58,956 KB |
testcase_21 | AC | 62 ms
58,008 KB |
testcase_22 | AC | 68 ms
57,740 KB |
testcase_23 | AC | 73 ms
60,172 KB |
testcase_24 | AC | 78 ms
59,416 KB |
testcase_25 | AC | 56 ms
57,772 KB |
testcase_26 | AC | 57 ms
57,384 KB |
testcase_27 | AC | 98 ms
58,544 KB |
testcase_28 | AC | 92 ms
58,000 KB |
testcase_29 | AC | 61 ms
58,012 KB |
testcase_30 | AC | 62 ms
57,512 KB |
testcase_31 | AC | 83 ms
58,920 KB |
testcase_32 | AC | 64 ms
58,684 KB |
testcase_33 | AC | 58 ms
57,120 KB |
testcase_34 | AC | 105 ms
58,052 KB |
testcase_35 | AC | 97 ms
58,836 KB |
testcase_36 | AC | 109 ms
58,972 KB |
testcase_37 | AC | 108 ms
57,572 KB |
ソースコード
def var_calc(n): var = 0 for i in range(1, n + 1): var += i * i return var def shirabe(n): var = 0 for i in range(1, n + 1): var += i * i a = [0] * (var + 1) a[0] = 1 for i in range(1, n + 1): b = a[::] for j in range(var + 1): if i * i + j <= var and a[j]: b[i * i + j] = 1 a = b tar = [] for i in range(var + 1): if a[i] == 0: tar.append(i) return tar # 1 + 4 + 9 + 16 + 25 + 36 umekomi = [2, 3, 6, 7, 8, 11, 12, 15, 18, 19, 22, 23, 24, 27, 28, 31, 32, 33, 43, 44, 47, 48, 60, 67, 72, 76, 92, 96, 108, 112, 128] r, b = map(int,input().split()) ub = 2 * 10 ** 6 lb = 1 while ub - lb > 1: t = (ub + lb) // 2 av = var_calc(t) if r + b < av: ub = t continue if t <= 16: g = [i * i for i in range(1, t + 1)] mode = 0 for i in range(1 << t): at = 0 bt = 0 for j in range(t): if i >> j & 1: at += g[j] else: bt += g[j] if at <= r and bt <= b: mode = 1 break if mode: lb = t else: ub = t else: norep = set(umekomi) for i in umekomi: norep.add(av - i) if r >= av or b >= av: lb = t continue good = 0 for i in range(0, min(r+1, 10000)): if r - i in norep: continue if av - (r - i) > b: continue if av - (r - i) < 0: continue if av - (r - i) in norep: continue good = 1 break if good: lb = t else: ub = t print(lb)