結果
| 問題 | No.461 三角形はいくつ? |
| コンテスト | |
| ユーザー |
りあん
|
| 提出日時 | 2016-12-09 15:57:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,472 bytes |
| 記録 | |
| コンパイル時間 | 1,720 ms |
| コンパイル使用メモリ | 173,936 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-29 03:25:40 |
| 合計ジャッジ時間 | 7,510 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 WA * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long double eps = 1e-17L;
cin >> n;
vector<long double> lines[3];
for (int i = 0; i < 3; i++)
{
lines[i].emplace_back(0.0);
}
for (int i = 0; i < n; i++)
{
int p, a, b;
cin >> p >> a >> b;
lines[p].emplace_back(b / (long double)(a + b));
}
for (int i = 0; i < 3; i++)
sort(lines[i].begin(), lines[i].end());
long long ans = 0;
for (auto a : lines[0])
{
for (auto b : lines[1])
{
if (a + b > 1 + eps) continue;
int ok = 0, ng = lines[2].size();
while (ok < ng - 1)
{
int m = (ok + ng) >> 1;
double c = lines[2][m];
if (a + c < 1 + eps && b + c < 1 + eps)
ok = m;
else
ng = m;
}
ans += ok + 1;
int l = 0, r = lines[2].size() - 1;
while (1)
{
int m = (l + r) >> 1;
double c = lines[2][m];
if (abs(a + b + c - 1) < eps)
{
--ans;
break;
}
if (l >= r) break;
if (a + b + c < 1)
l = m + 1;
else
r = m - 1;
}
}
}
cout << ans << "\n";
return 0;
}
りあん