結果

問題 No.461 三角形はいくつ?
ユーザー kmjpkmjp
提出日時 2016-12-12 00:33:08
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 300 ms / 5,000 ms
コード長 1,362 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 166,140 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 04:13:14
合計ジャッジ時間 7,035 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int P[404040],A[404040],B[404040];
vector<long double> V[3];
ll ret;

void solve() {
	int i,j,k,l,r,x,y; string s;
	long double eps=1e-18;
	
	cin>>N;
	FOR(i,N) {
		cin>>P[i]>>A[i]>>B[i];
		V[P[i]].push_back((long double)1.0*A[i]/(A[i]+B[i]));
	}
	FOR(i,3) sort(ALL(V[i]));
	ll ret=N+1;
	FORR(r,V[0]) {
		FORR(r2,V[1]) if(r+r2>1+eps) ret++;
		FORR(r2,V[2]) if(r+r2>1+eps) ret++;
	}
	FORR(r,V[1]) {
		FORR(r2,V[2]) if(r+r2>1+eps) ret++;
	}
	FORR(r,V[0]) FORR(r2,V[1]) {
		if(r+r2<1-eps) continue;
		long double hoge=1-min(r,r2);
		ret += V[2].end()-lower_bound(ALL(V[2]),hoge-eps);
		hoge=2-(r+r2);
		ret-=lower_bound(ALL(V[2]),hoge+eps)-lower_bound(ALL(V[2]),hoge-eps);
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0