結果
問題 |
No.3141 Balancing with X=>O Flip
|
ユーザー |
![]() |
提出日時 | 2025-05-16 23:02:32 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 405 bytes |
コンパイル時間 | 12,446 ms |
コンパイル使用メモリ | 237,744 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-16 23:02:55 |
合計ジャッジ時間 | 14,725 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 23 WA * 2 |
ソースコード
package main import . "fmt" func main(){ var n int var s string Scan(&n,&s) if n%2==1 { Println("No") return } bs:=[]byte(s) x,y:=0,0 for i,c:=range bs { if c=='(' { x++ } else if x>0 { x-- } else { y++ } for i>=0&&y>0&&c==')'&&i+1<n&&bs[i+1]=='(' { bs[i]='(' bs[i+1]=')' y-- //x++ i-- } } if x==0&&y==0 { Println("Yes") } else { Println("No") } }