結果
問題 |
No.1765 While Shining
|
ユーザー |
![]() |
提出日時 | 2022-01-02 08:27:55 |
言語 | TypeScript (5.7.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 385 bytes |
コンパイル時間 | 8,765 ms |
コンパイル使用メモリ | 228,844 KB |
実行使用メモリ | 53,072 KB |
最終ジャッジ日時 | 2024-12-31 16:42:41 |
合計ジャッジ時間 | 12,829 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 10 WA * 12 |
ソースコード
function main(input) { const n = Number(input[0]); const arr = input[1].split(" "); const cnt = []; let now = 0; for(let i=n-2; i>=0; i--) { if(arr[i+1] !== arr[i]) now++; else now = 1; cnt[i] = now; } let ans = 0; for(let i=0; i<n; i++) { if(arr[i] === "1") ans += cnt[i]; } console.log(ans); } main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));