結果
問題 | No.490 yukiソート |
ユーザー | fmhr |
提出日時 | 2017-03-10 23:25:25 |
言語 | Go (1.22.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,536 bytes |
コンパイル時間 | 11,312 ms |
コンパイル使用メモリ | 211,892 KB |
実行使用メモリ | 5,840 KB |
最終ジャッジ日時 | 2023-09-06 16:01:48 |
合計ジャッジ時間 | 33,560 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,664 KB |
testcase_01 | AC | 3 ms
5,668 KB |
testcase_02 | AC | 3 ms
5,664 KB |
testcase_03 | AC | 2 ms
5,672 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | WA | - |
testcase_25 | AC | 3 ms
5,664 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 2 ms
5,668 KB |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) func main() { ns := NewScanner() var n int n = ns.NextInt() a := make([]int, n) for i := 0; i < n; i++ { a[i] = ns.NextInt() } for i := 0; i < 2*n-3; i++ { for p := 0; p < i; p++ { // for q := p + 1; q < n; q++ { for q := n - 1; q > p; q-- { if p+q == i { if a[p] > a[q] { // log.Println(a[p], a[q]) a[p], a[q] = a[q], a[p] } } else if p+q > i { break } } } } // sort.Ints(a) for i, b := range a { fmt.Print(b) if i < len(a)-1 { fmt.Print(" ") } else if i == len(a)-1 { fmt.Print("\n") } } } type Scanner struct { r *bufio.Reader buf []byte p int } func NewScanner() *Scanner { rdr := bufio.NewReaderSize(os.Stdin, 10000000) return &Scanner{r: rdr} } func (s *Scanner) Next() string { s.pre() start := s.p for ; s.p < len(s.buf); s.p++ { if s.buf[s.p] == ' ' { break } } result := string(s.buf[start:s.p]) s.p++ return result } func (s *Scanner) NextLine() string { s.pre() start := s.p s.p = len(s.buf) return string(s.buf[start:]) } func (s *Scanner) NextInt() int { v, _ := strconv.Atoi(s.Next()) return v } func (s *Scanner) NextInt64() int64 { v, _ := strconv.ParseInt(s.Next(), 10, 64) return v } func (s *Scanner) pre() { if s.p >= len(s.buf) { s.readLine() s.p = 0 } } func (s *Scanner) readLine() { s.buf = make([]byte, 0) for { l, p, e := s.r.ReadLine() if e != nil { panic(e) } s.buf = append(s.buf, l...) if !p { break } } }