結果

問題 No.461 三角形はいくつ?
ユーザー YamyukiYamyuki
提出日時 2016-12-13 14:26:32
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,243 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 23,004 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 09:23:36
合計ジャッジ時間 6,518 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 200 ms
5,376 KB
testcase_06 AC 103 ms
5,376 KB
testcase_07 AC 125 ms
5,376 KB
testcase_08 AC 84 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 25 ms
5,376 KB
testcase_11 AC 147 ms
5,376 KB
testcase_12 AC 63 ms
5,376 KB
testcase_13 AC 220 ms
5,376 KB
testcase_14 AC 207 ms
5,376 KB
testcase_15 AC 218 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 273 ms
5,376 KB
testcase_19 AC 272 ms
5,376 KB
testcase_20 AC 220 ms
5,376 KB
testcase_21 AC 211 ms
5,376 KB
testcase_22 AC 207 ms
5,376 KB
testcase_23 AC 30 ms
5,376 KB
testcase_24 AC 27 ms
5,376 KB
testcase_25 AC 27 ms
5,376 KB
testcase_26 AC 26 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 367 ms
5,376 KB
testcase_30 AC 333 ms
5,376 KB
testcase_31 AC 386 ms
5,376 KB
testcase_32 AC 405 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 62 ms
5,376 KB
testcase_37 AC 54 ms
5,376 KB
testcase_38 AC 58 ms
5,376 KB
testcase_39 AC 49 ms
5,376 KB
testcase_40 WA -
testcase_41 AC 56 ms
5,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:47:9: warning: implicit declaration of function ‘qsort’ [-Wimplicit-function-declaration]
   47 |         qsort(hen[2].h,h[2],sizeof(double),cmp);
      |         ^~~~~
main.c:36:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:42:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |                 scanf("%d %ld %ld",&p,&a,&b);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

typedef struct {
	double h[4001];
} hens;

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

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

long search(double *hen,double max,int s,int e){
	if(e==s) return e;
	if(check(hen[(s+e)/2+1],max)>0){
		return search(hen,max,s,(s+e)/2);
	}else{
		return search(hen,max,(s+e)/2+1,e);
	}
}

int main(){
	int n,i,j,k;
	int p,h[3];
	double comp,s;
	hens hen[3];
	long a,b;
	long long c;
	scanf("%d",&n);
	for(i=0;i<3;i++){
		h[i]=1;
		hen[i].h[0]=0.0;
	}
	for(i=0;i<n;i++){
		scanf("%d %ld %ld",&p,&a,&b);
		hen[p].h[h[p]]=(double)b/(double)(a+b);
		h[p]++;
	}
	//for(i=0;i<3;i++){
	qsort(hen[2].h,h[2],sizeof(double),cmp);
	//}
	c=0;
	for(i=0;i<h[0];i++){
		for(j=0;j<h[1];j++){
			if(check(1.0,hen[0].h[i]+hen[1].h[j])==-1) continue;
			if(check(hen[0].h[i],hen[1].h[j])>0){
				s=1.0-hen[0].h[i];
			}else{
				s=1.0-hen[1].h[j];
			}
			comp=search(hen[2].h,s,0,h[2]-1);
			c+=(long long)(comp+1);
			if(check(hen[2].h[search(hen[2].h,1.0-hen[0].h[i]-hen[1].h[j],0,comp)],1.0-hen[0].h[i]-hen[1].h[j])==0) c--;
			}
	}
	printf("%lld\n",c);
	return 0;
}
0