結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-10 17:16:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 900 bytes |
| コンパイル時間 | 193 ms |
| コンパイル使用メモリ | 29,400 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-10 17:16:45 |
| 合計ジャッジ時間 | 1,023 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 1 WA * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:22: warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=]
52 | printf("%8.6lf",ans);
| ~~~~~^ ~~~
| | |
| | long double
| double
| %8.6Lf
main.cpp:4:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
4 | scanf("%d",&num);
| ~~~~~^~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d",&b[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(void){
int num = 0;
scanf("%d",&num);
long double ans = 0;
int A[num];
int *a = A;
int B[num];
int *b = B;
// 入力された値を配列に格納
for(int i = 0;i < num;i++){
scanf("%d",&a[i]);
}
// ソート昇順
for(int i = 0;i < num;i++){
for(int j = 0;j < num;j++){
if(a[i] < a[j]){
int tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
}
}
// 入力された値を配列に格納
for(int i = 0;i < num;i++){
scanf("%d",&b[i]);
}
// ソート降順
for(int i = 0;i < num;i++){
for(int j = 0;j < num;j++){
if(b[i] > b[j]){
int tmp = b[i];
b[i] = b[j];
b[j] = tmp;
}
}
}
// どちらが何回勝利するかカウントする
int countA = 0;
for(int i = 0;i < num;i++){
if(a[i] > b[i]){
countA++;
}
}
// 勝率の計算
ans = (long double)countA / (long double)num;
printf("%8.6lf",ans);
}
sasa