結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 141 ms
5,376 KB
testcase_06 AC 74 ms
5,376 KB
testcase_07 AC 89 ms
5,376 KB
testcase_08 AC 58 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 100 ms
5,376 KB
testcase_12 AC 46 ms
5,376 KB
testcase_13 AC 152 ms
5,376 KB
testcase_14 AC 146 ms
5,376 KB
testcase_15 AC 151 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 259 ms
5,376 KB
testcase_19 AC 271 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 150 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 35 ms
5,376 KB
testcase_26 AC 34 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 369 ms
5,376 KB
testcase_30 AC 336 ms
5,376 KB
testcase_31 AC 380 ms
5,376 KB
testcase_32 AC 395 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 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:45:9: warning: implicit declaration of function ‘qsort’ [-Wimplicit-function-declaration]
   45 |         qsort(hen[2].h,h[2],sizeof(double),cmp);
      |         ^~~~~
main.c:34:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:40:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |                 scanf("%d %ld %ld",&p,&a,&b);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

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


int check(double a,double b){
	if(a==b) return 0;
	if(a-b>0) return 1;
	return -1;
}


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

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 s;
	hens hen[3];
	long a,b,c,comp;
	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+=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("%ld\n",c);
	return 0;
}
0