結果

問題 No.322 Geometry Dash
ユーザー FF256grhyFF256grhy
提出日時 2015-12-15 01:19:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 26,344 KB
実行使用メモリ 4,608 KB
最終ジャッジ日時 2023-08-08 11:15:52
合計ジャッジ時間 5,387 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 32 ms
4,608 KB
testcase_05 AC 34 ms
4,528 KB
testcase_06 AC 37 ms
4,548 KB
testcase_07 AC 40 ms
4,536 KB
testcase_08 AC 41 ms
4,584 KB
testcase_09 AC 35 ms
4,604 KB
testcase_10 AC 37 ms
4,592 KB
testcase_11 AC 39 ms
4,548 KB
testcase_12 AC 41 ms
4,532 KB
testcase_13 AC 43 ms
4,528 KB
testcase_14 AC 38 ms
4,548 KB
testcase_15 AC 39 ms
4,532 KB
testcase_16 AC 41 ms
4,532 KB
testcase_17 AC 43 ms
4,548 KB
testcase_18 AC 44 ms
4,536 KB
testcase_19 AC 40 ms
4,484 KB
testcase_20 AC 41 ms
4,484 KB
testcase_21 AC 43 ms
4,536 KB
testcase_22 AC 45 ms
4,532 KB
testcase_23 AC 45 ms
4,544 KB
testcase_24 AC 42 ms
4,476 KB
testcase_25 AC 42 ms
4,536 KB
testcase_26 AC 44 ms
4,476 KB
testcase_27 AC 46 ms
4,536 KB
testcase_28 AC 46 ms
4,584 KB
testcase_29 AC 37 ms
4,376 KB
testcase_30 AC 41 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#define MAX 100000

int n, t[MAX], d[MAX];

int ind[MAX], temp[MAX];

int comp(int i, int j, int m, int e) {
	if(j > e) { return 1; }
	if(i > m) { return 0; }
	return t[ ind[i] ] * d[ ind[j] ] > t[ ind[j] ] * d[ ind[i] ];
}

void sort(int s, int e) {
	if(s == e) { return; }
	
	int m = (s + e) / 2;
	sort(s    , m);
	sort(m + 1, e);
	
	int i = s, j = m + 1, p = s;
	while(i <= m || j <= e) {
		if( comp(i, j, m, e) ) {
			temp[p] = ind[i];
			i++;
		} else {
			temp[p] = ind[j];
			j++;
		}
		p++;
	}
	
	for(p = s; p <= e; p++) { ind[p] = temp[p]; }
	
	return;
}

int main(void) {
	scanf("%d", &n);
	int i;
	for(i = 0; i < n; i++) { scanf("%d", &t[i]); }
	for(i = 0; i < n; i++) { scanf("%d", &d[i]); }
	
	for(i = 0; i < n; i++) { ind[i] = i; }
	sort(0, n - 1);
	
	for(i = 0; i < n; i++) { printf("%s%d", (i == 0 ? "" : " "), ind[i] + 1); }
	printf("\n");
	
	return 0;
}
0