結果

問題 No.1435 Mmm......
ユーザー kojihashimoto-kobekojihashimoto-kobe
提出日時 2021-03-25 02:45:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 28,840 KB
最終ジャッジ日時 2023-08-17 22:54:13
合計ジャッジ時間 15,473 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,780 KB
testcase_01 AC 16 ms
7,744 KB
testcase_02 AC 16 ms
7,812 KB
testcase_03 AC 16 ms
7,804 KB
testcase_04 AC 16 ms
7,792 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 627 ms
23,776 KB
testcase_12 AC 575 ms
22,948 KB
testcase_13 AC 553 ms
22,676 KB
testcase_14 WA -
testcase_15 AC 784 ms
28,720 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 801 ms
28,840 KB
testcase_19 AC 590 ms
23,668 KB
testcase_20 WA -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

t = 1

ans = 0
l = 0
while l < n-1:
  M = sorted(a[l:l+t+1])[-1]
  m1 = sorted(a[l:l+t+1])[0]
  m2 = sorted(a[l:l+t+1])[1]
  while l + t+1 <= n-1:
    t += 1
    x = M
    y = m1
    z = m2
    if a[l+t] > x:
      M = a[l+t]
    if y <= a[l+t] <= z:
      m2 = a[l+t]
    if a[l+t] < y:
      m2 = y
      m1 = a[l+t]
    if M <= m1 + m2:
      continue
    if M > m1 + m2:
      break
  if l + t == n-1:
    ans += t
    l += 1
    t -= 1
  else:
    ans += t -1
    l += 1
    if t-1 == 1:
      t = 1
    else:
      t = t -2


print(ans)
0