結果

問題 No.480 合計
ユーザー Masaki KitaguchiMasaki Kitaguchi
提出日時 2022-01-10 17:09:03
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 7,076 KB
実行使用メモリ 39,808 KB
最終ジャッジ日時 2024-04-26 20:11:42
合計ジャッジ時間 2,957 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
39,552 KB
testcase_01 AC 70 ms
39,552 KB
testcase_02 AC 70 ms
39,680 KB
testcase_03 AC 69 ms
39,680 KB
testcase_04 AC 70 ms
39,680 KB
testcase_05 AC 69 ms
39,552 KB
testcase_06 AC 68 ms
39,808 KB
testcase_07 AC 68 ms
39,552 KB
testcase_08 AC 69 ms
39,552 KB
testcase_09 AC 70 ms
39,680 KB
testcase_10 AC 68 ms
39,552 KB
testcase_11 AC 68 ms
39,552 KB
testcase_12 AC 68 ms
39,808 KB
testcase_13 AC 67 ms
39,552 KB
testcase_14 AC 67 ms
39,552 KB
testcase_15 AC 67 ms
39,808 KB
testcase_16 AC 68 ms
39,552 KB
testcase_17 AC 68 ms
39,552 KB
testcase_18 AC 68 ms
39,680 KB
testcase_19 AC 69 ms
39,808 KB
testcase_20 AC 68 ms
39,552 KB
testcase_21 AC 68 ms
39,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const lineIter = (function* () {
  const stdin = require('fs').readFileSync(process.stdin.fd, 'utf8');
  const lines = stdin.trim().split('\n');
  for (const line of lines) {
    yield line.trim();
  }
})();
const wordIter = (function* () {
  while (true) {
    const { done, value: line } = lineIter.next();
    if (done) {
      break;
    }
    const words = line.split(' ');
    for (const word of words) {
      yield word;
    }
  }
})();
const read = () => wordIter.next().value;

const main = async () => {
  const n = parseInt(read());

  const sum = Array(n)
    .fill()
    .map((_, i) => i + 1)
    .reduce((acc, num) => acc + num, 0);

  console.log(`${sum}`);
};

(async () => {
  try {
    await main();
  } catch (e) {
    console.error(e);
  }
})();
0