結果

問題 No.461 三角形はいくつ?
ユーザー YamyukiYamyuki
提出日時 2016-12-12 14:21:35
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 938 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 22,780 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 03:23:17
合計ジャッジ時間 21,575 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 19 ms
5,376 KB
testcase_26 AC 20 ms
5,376 KB
testcase_27 AC 10 ms
5,376 KB
testcase_28 AC 11 ms
5,376 KB
testcase_29 AC 1,652 ms
5,376 KB
testcase_30 AC 816 ms
5,376 KB
testcase_31 AC 2,950 ms
5,376 KB
testcase_32 AC 3,714 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:29:17: warning: implicit declaration of function ‘qsort’ [-Wimplicit-function-declaration]
   29 |                 qsort(hen[i],h[i],sizeof(double),cmp);
      |                 ^~~~~
main.c:18:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:24:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                 scanf("%d %ld %ld",&p,&a,&b);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int cmp(const void *a,const void *b){
	return *(double*)a-*(double*)b;
}

int check(double a,double b){
	if(a-b>-0.0000000000001 && a-b<0.00000000000001) return 0;
	if(a-b>0) return 1;
	return -1;
}

int main(){
	int n,i,j,k;
	int p,h[3];
	double hen[3][4001],comp;
	long a,b,c;
	scanf("%d",&n);
	for(i=0;i<3;i++){
		h[i]=1;
		hen[i][0]=1.0;
	}
	for(i=0;i<n;i++){
		scanf("%d %ld %ld",&p,&a,&b);
		hen[p][h[p]]=(double)a/(double)(a+b);
		h[p]++;
	}
	for(i=0;i<3;i++){
		qsort(hen[i],h[i],sizeof(double),cmp);
	}
	c=0;
	for(i=0;i<h[0];i++){
		for(j=h[1]-1;j>=0;j--){
			if(check(1.0-hen[0][i],hen[1][j])<=0){
				comp=(check(hen[0][i],hen[1][i])<=0)?1.0-hen[1][j]:1.0-hen[0][i];
				for(k=h[2]-1;k>=0;k--){
					if(check(comp,hen[2][k])<=0){
						if(check(2.0-hen[0][i]-hen[1][j],hen[2][k])!=0){
							c++;
						}
					}else{
						break;
					}
				}
			}else{
				break;
			}
		}
	}
	printf("%ld\n",c);
	return 0;
}
0