結果

問題 No.2008 Super Worker
ユーザー 👑 ygussanyygussany
提出日時 2022-07-15 21:31:07
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 978 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 30,100 KB
実行使用メモリ 9,744 KB
最終ジャッジ日時 2023-09-10 00:40:05
合計ジャッジ時間 3,891 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 0 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 77 ms
9,600 KB
testcase_24 AC 77 ms
9,664 KB
testcase_25 AC 77 ms
9,660 KB
testcase_26 AC 76 ms
9,600 KB
testcase_27 AC 77 ms
9,596 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 55 ms
9,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 1000000007;
double sup = 1e+12;

typedef struct {
	double key;
	int id;
} data;

void merge_sort(int n, data x[])
{
	static data y[200001] = {};
	if (n <= 1) return;
	merge_sort(n / 2, &(x[0]));
	merge_sort((n + 1) / 2, &(x[n/2]));
	
	int i, p, q;
	for (i = 0, p = 0, q = n / 2; i < n; i++) {
		if (p >= n / 2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, A[200001], B[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(B[i]));
	
	data d[200001];
	for (i = 1; i <= N; i++) {
		d[i-1].key = (B[i] == 1)? sup: (double)A[i] / (B[i] - 1);
		d[i-1].id = i;
	}
	merge_sort(N, d);
	
	long long ans = 0, tmp = 1;
	for (i = 0; i < N; i++) {
		ans += tmp * A[d[i].id];
		tmp = tmp * B[d[i].id] % Mod;
	}
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}
0