結果

問題 No.851 テストケース
ユーザー kou_kkk
提出日時 2025-09-10 12:25:49
言語 Nim
(2.2.0)
結果
AC  
実行時間 2 ms / 3,153 ms
コード長 401 bytes
コンパイル時間 5,184 ms
コンパイル使用メモリ 70,200 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-09-10 12:25:56
合計ジャッジ時間 6,290 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils, strutils

let
  input = stdin.lines.toSeq
  n = parseInt input[0]
  seq1 = input[1..^1]

if seq1.len != n:
  echo $'"' & "assert" & $'"'
  quit()

let
  xs = seq1.map parseInt

var
  a, b, c = 0

for x in xs:
  var tmp = x
  if tmp > a:
    swap(tmp, a)
  if tmp > b:
    swap(tmp, b)
  if tmp > c and (a != b or tmp != b):
    swap(tmp, c)

if b == c:
  echo b + c
else:
  echo a + c
0