結果

問題 No.851 テストケース
コンテスト
ユーザー kou_kkk
提出日時 2025-09-10 12:25:49
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 3,153 ms
+ 292µs
コード長 401 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,443 ms
コンパイル使用メモリ 70,720 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-14 23:40:57
合計ジャッジ時間 4,932 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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