結果

問題 No.461 三角形はいくつ?
ユーザー ytftytft
提出日時 2021-04-05 00:23:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,421 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 177,940 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 12:01:14
合計ジャッジ時間 7,224 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 154 ms
4,376 KB
testcase_06 AC 79 ms
4,376 KB
testcase_07 AC 93 ms
4,380 KB
testcase_08 AC 66 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 19 ms
4,376 KB
testcase_11 AC 111 ms
4,380 KB
testcase_12 AC 51 ms
4,376 KB
testcase_13 AC 176 ms
4,376 KB
testcase_14 AC 166 ms
4,376 KB
testcase_15 AC 177 ms
4,380 KB
testcase_16 AC 10 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 327 ms
4,380 KB
testcase_19 AC 327 ms
4,376 KB
testcase_20 AC 172 ms
4,380 KB
testcase_21 AC 179 ms
4,376 KB
testcase_22 AC 177 ms
4,376 KB
testcase_23 AC 36 ms
4,376 KB
testcase_24 AC 33 ms
4,380 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 6 ms
4,380 KB
testcase_29 AC 74 ms
4,376 KB
testcase_30 AC 37 ms
4,376 KB
testcase_31 AC 137 ms
4,376 KB
testcase_32 AC 180 ms
4,380 KB
testcase_33 AC 6 ms
4,380 KB
testcase_34 AC 6 ms
4,376 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 60 ms
4,376 KB
testcase_37 AC 57 ms
4,380 KB
testcase_38 AC 61 ms
4,376 KB
testcase_39 AC 54 ms
4,376 KB
testcase_40 AC 57 ms
4,380 KB
testcase_41 AC 62 ms
4,380 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<vector<long double>> lines(3,vector<long double>(1,0));
    int p;
    long long ans=0;
    long double 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(),[](long double a,long double b){return a<b;});
    }
    int m,M,mid;
    sort(lines.begin(),lines.end(),[](vector<long double>& a,vector<long double>& 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