結果
| 問題 | No.461 三角形はいくつ? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 14:41:22 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,201 bytes |
| コンパイル時間 | 129 ms |
| コンパイル使用メモリ | 23,384 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 01:00:56 |
| 合計ジャッジ時間 | 6,048 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 WA * 3 |
コンパイルメッセージ
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
typedef struct {
double h[4001];
} hens;
int check(double a,double b){
if(a-b>-0.000000000000001 && a-b<0.000000000000001) 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;
}