結果

問題 No.322 Geometry Dash
ユーザー FF256grhy
提出日時 2015-12-15 01:19:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 23,552 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 16:53:05
合計ジャッジ時間 4,650 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0