結果
| 問題 |
No.1765 While Shining
|
| コンテスト | |
| ユーザー |
monaka
|
| 提出日時 | 2022-01-02 08:33:24 |
| 言語 | TypeScript (5.7.2) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 387 bytes |
| コンパイル時間 | 8,906 ms |
| コンパイル使用メモリ | 228,340 KB |
| 実行使用メモリ | 52,444 KB |
| 最終ジャッジ日時 | 2024-12-31 16:42:54 |
| 合計ジャッジ時間 | 12,810 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
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-1; i++) {
if(arr[i] === "1") ans += cnt[i];
}
console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));
monaka