結果

問題 No.178 美しいWhitespace (1)
ユーザー rihitorihito
提出日時 2019-01-14 09:05:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,048 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-08-30 20:26:37
合計ジャッジ時間 1,764 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 15 ms
7,836 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 17 ms
7,848 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 17 ms
7,856 KB
testcase_12 AC 17 ms
7,748 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 18 ms
7,804 KB
testcase_19 WA -
testcase_20 AC 18 ms
7,856 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 18 ms
7,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 完璧にできる場合と完璧にできない場合がポイントと考える。
# a+4bのソースコード長をMAXとすると、(MAX-(a+4b))/2が必要な全角スペースの回数のc。
# (MAX-(a+4b))/2が割り切れない場合は、「完璧にできない場合」→print(-1)と返す。

# この考え方をすると、
# 1.全てのソースコード長(W)をリストに格納し、maxの関数を使って最大値(MAXI)を求める。
# 2.(MAX-(a+4b))/2を各ソースコード長で行い、完璧かどうかの判定、MAXまでいくつ全角スペース(Em_Spa)が必要かを求める。
# という方針が立つので、これに基づいてコードを書く。

N = int(input())
W = []
Em_Spa = 0

# 方針1を実行。
for i in range(N):
    a, b = map(int, input().split())
    W.append(a + b*4)
MAXI=max(W)

#方針2を実行
for j in W:
    if (MAXI - j)%2 == 0:
        Em_Spa += (MAXI - j)/2
    else:
        print(-1)
        break

if (MAXI - j)%2 == 0:
    print(Em_Spa)

#最後が美しくない……
0