結果

問題 No.461 三角形はいくつ?
ユーザー ytftytft
提出日時 2021-04-05 00:38:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,551 bytes
コンパイル時間 6,111 ms
コンパイル使用メモリ 465,052 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 12:19:10
合計ジャッジ時間 74,837 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 2,801 ms
4,380 KB
testcase_06 AC 1,538 ms
4,376 KB
testcase_07 AC 1,818 ms
4,380 KB
testcase_08 AC 1,221 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 354 ms
4,380 KB
testcase_11 AC 2,085 ms
4,380 KB
testcase_12 AC 879 ms
4,376 KB
testcase_13 AC 3,165 ms
4,380 KB
testcase_14 AC 2,994 ms
4,376 KB
testcase_15 AC 3,226 ms
4,380 KB
testcase_16 AC 222 ms
4,376 KB
testcase_17 AC 216 ms
4,376 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 WA -
testcase_21 AC 3,245 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 25 ms
4,376 KB
testcase_26 AC 25 ms
4,376 KB
testcase_27 AC 24 ms
4,380 KB
testcase_28 AC 25 ms
4,376 KB
testcase_29 AC 1,226 ms
4,380 KB
testcase_30 AC 575 ms
4,376 KB
testcase_31 AC 2,334 ms
4,380 KB
testcase_32 AC 3,108 ms
4,376 KB
testcase_33 AC 19 ms
4,376 KB
testcase_34 AC 19 ms
4,376 KB
testcase_35 AC 20 ms
4,380 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 #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Real=mp::number<mp::cpp_dec_float<100>>;
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<vector<Real>> lines(3,vector<Real>(1,0));
    int p;
    long long ans=0;
    Real a,b;
    for(int i=0;i<N;i++){
        cin>>p>>a>>b;
        lines[p].push_back(b/(b+a));
    }
    for(int i=0;i<3;i++){
        sort(lines[i].begin(),lines[i].end(),[](Real a,Real b){return a<b;});
    }
    int m,M,mid;
    sort(lines.begin(),lines.end(),[](vector<Real>& a,vector<Real>& b){return a.size()<b.size();});
    for(int i=0;i<lines[0].size();i++){
        for(int j=0;j<lines[1].size();j++){
            if(lines[0][i]+lines[1][j]>1){
                continue;
            }
            m=0;
            M=lines[2].size();
            while(M-m>1){
                mid=(m+M)/2;
                if(lines[2][mid]+lines[0][i]+lines[1][j]>1){
                    M=mid;
                }else{
                    m=mid;
                }
            }

            if(lines[2][m]+lines[0][i]+lines[1][j]==1){
                ans-=1;
            }
            m=-1;
            M=lines[2].size();
            while(M-m>1){
                mid=(m+M)/2;
                if(lines[2][mid]+max(lines[0][i],lines[1][j])>1){
                    M=mid;
                }else{
                    m=mid;
                }
            }
            ans+=m+1;
        }
    }
    cout<<ans<<endl;
}
0