結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
|
提出日時 | 2015-03-05 13:53:25 |
言語 | Go1.4 (1.4.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 824 bytes |
コンパイル時間 | 450 ms |
コンパイル使用メモリ | 33,884 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 00:10:40 |
合計ジャッジ時間 | 1,187 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 9 |
ソースコード
package main import ( "bufio" "os" "strconv" "fmt" ) var s = bufio.NewScanner(os.Stdin) func next() string { s.Split(bufio.ScanWords) s.Scan() return s.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i } func nextLong() int64 { i, e := strconv.ParseInt(next(), 10, 64) if e != nil { panic(e) } return i } func main() { D := [3]int{} D[0] = nextInt() D[1] = nextInt() D[2] = nextInt() S := next() point := 0 for i := 0; i < len(S); i++ { var P = 0 switch { case S[i] == 'G': P = 0 case S[i] == 'C': P = 1 case S[i] == 'P': P = 2 } for i := -1; i < 2; i++ { p := (P + i + 3) % 3 if D[p] > 0 { D[p]-=1 if i == -1 { point+=3 }else if i == 0 { point+=1 } break } } } fmt.Println(point) }