結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
rocoder
|
| 提出日時 | 2017-08-03 09:20:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 819 bytes |
| コンパイル時間 | 140 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2024-10-11 20:19:39 |
| 合計ジャッジ時間 | 7,413 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 1 -- * 4 |
ソースコード
N=int(input ())
W=[int(i) for i in input (). split ()]
H=0
nd=0
for i in range (N):
H+=W[i]
if H%2==1:
nd=2
else:
H//=2
W.sort(reverse=True)
H-=W[0]
W.pop(0)
N-=1
if H<=0:
nd+=1
if H<0:
nd+=1
U=0
i=0
S=[0]*N
while nd<1:
while i<N and U<H:
S[i]=1
U+=W[i]
i+=1
# print (S)
# print (U)
if U==H:
nd=1
elif i<N:
i-=1
S[i]=0
U-=W[i]
i+=1
else:
i-=1
while i>=0 and S[i]==1:
S[i]=0
U-=W[i]
i-=1
# print (S)
while i>=0 and S[i]==0:
i-=1
if i<0:
nd=2
else:
S[i]=0
U-=W[i]
i+=1
if nd>=2:
p="impossible"
elif nd==1:
p="possible"
print (p)
rocoder