結果

問題 No.461 三角形はいくつ?
ユーザー chaemonchaemon
提出日時 2016-12-12 00:35:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,256 bytes
コンパイル時間 1,221 ms
コンパイル使用メモリ 96,728 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-06 18:53:57
合計ジャッジ時間 6,662 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 201 ms
5,376 KB
testcase_06 AC 106 ms
5,376 KB
testcase_07 AC 129 ms
5,376 KB
testcase_08 AC 85 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 26 ms
5,376 KB
testcase_11 AC 149 ms
5,376 KB
testcase_12 AC 63 ms
5,376 KB
testcase_13 AC 226 ms
5,376 KB
testcase_14 AC 212 ms
5,376 KB
testcase_15 AC 226 ms
5,376 KB
testcase_16 AC 74 ms
5,376 KB
testcase_17 AC 78 ms
5,376 KB
testcase_18 AC 112 ms
5,376 KB
testcase_19 AC 119 ms
5,376 KB
testcase_20 AC 232 ms
5,376 KB
testcase_21 AC 223 ms
5,376 KB
testcase_22 AC 220 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 89 ms
5,376 KB
testcase_26 AC 86 ms
5,376 KB
testcase_27 AC 5 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 182 ms
5,376 KB
testcase_30 AC 177 ms
5,376 KB
testcase_31 AC 179 ms
5,376 KB
testcase_32 AC 178 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 5 ms
5,376 KB
testcase_35 AC 5 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N;
vector<rn> t[3];
rn EPS=1e-12L;
vector<rn> listed;

int main(){
	cin>>N;
	REP(i,3)t[i].push_back(1.0L);
	listed.push_back(1.0L);
	REP(i,N){
		int p,a,b;
		cin>>p>>a>>b;
		t[p].push_back((rn)a/(rn)(a+b));
		if(p==2)listed.push_back(t[p].back());
	}
	sort(ALL(listed));
	Int d = 0;
	REP(i,t[0].size())REP(j,t[1].size()){
		rn u = 2.0L-(t[0][i] + t[1][j]);
		d+=distance(lower_bound(ALL(listed),u-EPS),upper_bound(ALL(listed),u+EPS));
	}
	Int ans = 0;
	REP(i,t[0].size())REP(j,t[1].size()){
		if(t[0][i]+t[1][j]<1.0L-EPS)continue;
		rn u = max(1.0L-t[0][i],1.0L-t[1][j]);
		
		Int k = distance(lower_bound(ALL(listed),u-EPS),listed.end());
//		cout<<t[0][i]<<" "<<t[1][j]<<" "<<u<<" "<<k<<endl;
		ans+=k;
	}
//	cout<<ans<<" "<<d<<endl;
//	cout<<ans<<endl;
	cout<<ans-d<<endl;
	return 0;
}
0