結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
|
提出日時 | 2022-09-30 16:05:35 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 14,286 ms |
コンパイル使用メモリ | 222,632 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-12-22 18:52:54 |
合計ジャッジ時間 | 15,734 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
package mainimport ("bufio""fmt""os""strconv")func g(n int) int {return n * (n + 1) / 2}func main() {var sc = bufio.NewScanner(os.Stdin)sc.Split(bufio.ScanWords)sc.Scan()N, _ := strconv.Atoi(sc.Text())A := make([]bool, N)for i := 0; i < N; i++ {sc.Scan()A[i] = sc.Text() == "1"}count := g(N)l := 0for _, b := range A {if b {l++} else if l > 0 {count -= g(l)l = 0}}if l > 0 {count -= g(l)}fmt.Println(count)}