結果

問題 No.133 カードゲーム
ユーザー くれちーくれちー
提出日時 2016-11-20 00:05:40
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 23,040 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 10:25:00
合計ジャッジ時間 764 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 0 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 0 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 0 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:22:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:26:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         for (i = 0; i < n; i++) scanf("%d", &a[i]);
      |                                 ^~~~~~~~~~~~~~~~~~
main.c:27:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |         for (i = 0; i < n; i++) scanf("%d", &b[i]);
      |                                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int getrand(int min, int max) {
	return min + (int)(rand() * (max - min + 1.0) / (1.0 + RAND_MAX));
}

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void shuffle(int *d, int size) {
	int tmp1 = getrand(0, size - 1);
	int tmp2 = getrand(0, size - 1);
	swap(&d[tmp1], &d[tmp2]);
}

int main() {
	int n;
	scanf("%d", &n);

	int a[4], b[4];
	int i, j;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	for (i = 0; i < n; i++) scanf("%d", &b[i]);

	int cnta = 0, num = 1000;
	for (i = 0; i < num; i++) {
		shuffle(a, n);
		shuffle(b, n);
		int cnt = 0;
		for (j = 0; j < n; j++) {
			if (a[j] > b[j]) cnt++;
		}
		if (cnt > n / 2) cnta++;
	}

	printf("%.3lf\n", (double)cnta / num);
	return 0;
}
0