結果

問題 No.1765 While Shining
ユーザー monaka
提出日時 2022-01-02 08:32:49
言語 TypeScript
(5.7.2)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 9,008 ms
コンパイル使用メモリ 228,480 KB
実行使用メモリ 53,328 KB
最終ジャッジ日時 2024-12-31 16:43:07
合計ジャッジ時間 12,293 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
	}
	console.log(arr);
	console.log(cnt);
	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"));
0