結果
| 問題 |
No.2856 Junk Market Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-25 15:04:48 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 646 bytes |
| コンパイル時間 | 3,707 ms |
| コンパイル使用メモリ | 181,360 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-08-25 15:04:54 |
| 合計ジャッジ時間 | 3,857 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 |
ソースコード
import std;
void main () {
int N = readln.chomp.to!int;
auto A = readln.split.to!(int[]);
auto B = readln.split.to!(int[]);
auto C = new int[](2 * N);
foreach (i; 0..2 * N) C[i] = A[i] + B[i];
auto index = iota(2 * N).array;
index.sort!((a, b) => C[a] < C[b]);
long X = 0, Y = 0;
foreach (i, v; index) {
if (i % 2 == 0) X += A[v];
if (i % 2 == 1) Y += B[v];
}
writeln(X - Y);
}
void read (T...) (string S, ref T args) {
import std.conv : to;
import std.array : split;
auto buf = S.split;
foreach (i, ref arg; args) {
arg = buf[i].to!(typeof(arg));
}
}