結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  ___0_u_0___ | 
| 提出日時 | 2019-02-12 11:24:25 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 535 bytes | 
| コンパイル時間 | 363 ms | 
| コンパイル使用メモリ | 37,728 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-13 09:19:51 | 
| 合計ジャッジ時間 | 1,180 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:9:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   for (int i = 0; i < n; i++) scanf("%d", &a[i]);
      |                               ~~~~~^~~~~~~~~~~~~
main.cpp:10:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   for (int i = 0; i < n; i++) scanf("%d", &b[i]);
      |                               ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#include<cstdio>
#include<algorithm>
using namespace std;
int n, a[4], b[4];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  int win = 0, counter = 0;
  sort(a, a+n);
  sort(b, b+n);
  do {
    do {
      counter++;
      int temp = 0;
      for (int i = 0; i < n; i++) if (a[i] > b[i]) temp++;
      if (temp * 2 > n) win++;
    } while (next_permutation(b, b+n));
  } while (next_permutation(a, a+n));
  printf("%f\n", (double)win / counter);
}
            
            
            
        