結果

問題 No.322 Geometry Dash
ユーザー FF256grhyFF256grhy
提出日時 2015-12-15 01:19:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 23,680 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 04:17:58
合計ジャッジ時間 4,675 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 33 ms
5,376 KB
testcase_05 AC 38 ms
5,376 KB
testcase_06 AC 41 ms
5,376 KB
testcase_07 AC 44 ms
5,376 KB
testcase_08 AC 45 ms
5,376 KB
testcase_09 AC 37 ms
5,376 KB
testcase_10 AC 40 ms
5,376 KB
testcase_11 AC 43 ms
5,376 KB
testcase_12 AC 45 ms
5,376 KB
testcase_13 AC 46 ms
5,376 KB
testcase_14 AC 42 ms
5,376 KB
testcase_15 AC 42 ms
5,376 KB
testcase_16 AC 44 ms
5,376 KB
testcase_17 AC 47 ms
5,376 KB
testcase_18 AC 48 ms
5,376 KB
testcase_19 AC 43 ms
5,376 KB
testcase_20 AC 44 ms
5,376 KB
testcase_21 AC 47 ms
5,376 KB
testcase_22 AC 48 ms
5,376 KB
testcase_23 AC 48 ms
5,376 KB
testcase_24 AC 45 ms
5,376 KB
testcase_25 AC 46 ms
5,376 KB
testcase_26 AC 48 ms
5,376 KB
testcase_27 AC 50 ms
5,376 KB
testcase_28 AC 50 ms
5,376 KB
testcase_29 AC 40 ms
5,376 KB
testcase_30 AC 44 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:42:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |         for(i = 0; i < n; i++) { scanf("%d", &t[i]); }
      |                                  ~~~~~^~~~~~~~~~~~~
main.cpp:43:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |         for(i = 0; i < n; i++) { scanf("%d", &d[i]); }
      |                                  ~~~~~^~~~~~~~~~~~~

ソースコード

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