結果

問題 No.2590 100000 Days of Christmas
ユーザー k82bk82b
提出日時 2023-12-24 17:01:06
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 883 bytes
コンパイル時間 3,457 ms
コンパイル使用メモリ 172,528 KB
実行使用メモリ 9,592 KB
最終ジャッジ日時 2023-12-24 17:01:12
合計ジャッジ時間 6,253 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 80 ms
6,692 KB
testcase_07 AC 65 ms
6,692 KB
testcase_08 AC 135 ms
7,076 KB
testcase_09 AC 60 ms
9,592 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 128 ms
7,080 KB
testcase_21 AC 134 ms
7,076 KB
testcase_22 AC 123 ms
6,952 KB
testcase_23 AC 127 ms
7,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main() {
	auto N = readln.chomp.to!int;
	alias Entry = Tuple!(string, "s", long, "x");
	auto S = new Entry[N];
	foreach (i; 0 .. N) {
		S[i].s = readln.chomp;
		S[i].x = cast(long)(i + 1) * (N - i);
	}
	S.sort;
	for (int i = 0; i < N; ) {
		int j = i;
		long sum;
		while (j < N && S[i].s == S[j].s) sum += S[j++].x;
		writeln(sum, ' ', S[i].s);
		i = j;
	}
}

import std, core.bitop;
bool chmin(T)(ref T A, T B) { if (A > B) { A = B; return true; } else { return false; } }
bool chmax(T)(ref T A, T B) { if (A < B) { A = B; return true; } else { return false; } }
int lowerBound(T)(T[] ar, T x) { int l = -1, r = cast(int)(ar.length); while (r - l > 1) { int mid = l + r >> 1; (ar[mid] < x ? l : r) = mid; } return r; }
int upperBound(T)(T[] ar, T x) { int l = -1, r = cast(int)(ar.length); while (r - l > 1) { int mid = l + r >> 1; (ar[mid] > x ? r : l) = mid; } return r; }
0