結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  toshiro_yanagi | 
| 提出日時 | 2018-06-21 02:06:28 | 
| 言語 | Nim (2.2.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 362 bytes | 
| コンパイル時間 | 3,441 ms | 
| コンパイル使用メモリ | 65,852 KB | 
| 実行使用メモリ | 9,472 KB | 
| 最終ジャッジ日時 | 2024-06-30 17:33:34 | 
| 合計ジャッジ時間 | 5,389 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 WA * 16 | 
ソースコード
import strutils, sequtils, algorithm
var
  N = stdin.readLine.parseInt
  a = stdin.readLine.split.map parseInt
  cnt_S = int.high
  cnt_L = int.low
if a != a.sorted(cmp):
  for a_i in a:
    if a_i == 1: break
    cnt_S = min(cnt_S, a_i)
  for a_i in a.reversed:
    if a_i == N: break
    cnt_L = max(cnt_L, a_i)
  echo max(cnt_L, N - cnt_S)
else:
  echo 0
            
            
            
        