Submission #5568780


Source Code Expand

Copy
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  const scanIntArray = (length: number) => {
    const array = new Array<number>(length);
    for (let i = 0; i < length; i++) array[i] = parseInt(scan());

    return array;
  };

  return { scan, scanInt, scanIntArray };
};

// ----

const descendingSorter = (a: number, b: number) => b - a;

// ----

function Main(input: string): void {
  const { scanInt, scanIntArray } = createScanFunctions(input);
  const n = scanInt();
  const a = scanIntArray(3 * n);

  a.sort(descendingSorter);

  let totalStrength = 0;
  const len = 2 * n;

  for (let i = 1; i < len; i += 2) {
    totalStrength += a[i];
  }

  log(totalStrength);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Submission Info

Submission Time
Task A - AtCoder Group Contest
User fal190
Language TypeScript (2.1.6)
Score 300
Code Size 1202 Byte
Status
Exec Time 216 ms
Memory 16460 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 00_example_01.txt, 00_example_02.txt
All 300 / 300 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt
Case Name Status Exec Time Memory
00_example_01.txt 54 ms 7372 KB
00_example_02.txt 54 ms 7372 KB
01.txt 53 ms 7372 KB
02.txt 54 ms 7500 KB
03.txt 54 ms 11468 KB
04.txt 53 ms 7372 KB
05.txt 70 ms 8416 KB
06.txt 131 ms 16460 KB
07.txt 81 ms 11340 KB
08.txt 213 ms 15048 KB
09.txt 216 ms 15080 KB
10.txt 214 ms 15112 KB