結果

問題 No.1045 直方体大学
ユーザー xenon_motsuxenon_motsu
提出日時 2019-11-18 18:54:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,346 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 93,012 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 14:49:53
合計ジャッジ時間 39,896 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,911 ms
5,248 KB
testcase_01 AC 1,910 ms
5,376 KB
testcase_02 AC 1,909 ms
5,376 KB
testcase_03 AC 1,909 ms
5,376 KB
testcase_04 AC 1,910 ms
5,376 KB
testcase_05 AC 1,909 ms
5,376 KB
testcase_06 AC 1,911 ms
5,376 KB
testcase_07 AC 1,910 ms
5,376 KB
testcase_08 AC 1,911 ms
5,376 KB
testcase_09 AC 1,910 ms
5,376 KB
testcase_10 AC 1,910 ms
5,376 KB
testcase_11 AC 1,908 ms
5,376 KB
testcase_12 AC 1,910 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 1,911 ms
5,376 KB
testcase_15 AC 1,910 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1,910 ms
5,376 KB
testcase_18 AC 1,909 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//乱択解

#include <iostream>
#include <vector>
#include <algorithm>
#include <random>

struct cube{
    int a, b, c;
    bool operator<(const cube&x){
        return a == x.a ? b < x.b : a < x.a;
    }
};

int main(){
    time_t s=clock();
    double lim=CLOCKS_PER_SEC*1.9;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    int N,K,l,ans{0},i,k,j;
    std::cin >> N;
    std::vector<int> A(N), B(N), C(N),dp(N);
    std::vector<cube> vc(N);
    int n{1};
    for(i = 0; i < N; ++i){
        std::cin >> A[i] >> B[i] >> C[i];
        n*=3;
    }
    while(clock()-s<lim){
        K=mt()%n;
        for(i = 0; i < N; ++i){
            l = K % 3;
            if(l == 0) vc[i].a = A[i], vc[i].b = B[i], vc[i].c = C[i];
            if(l == 1) vc[i].a = B[i], vc[i].b = C[i], vc[i].c = A[i];
            if(l == 2) vc[i].a = C[i], vc[i].b = A[i], vc[i].c = B[i];
            if(vc[i].a > vc[i].b) std::swap(vc[i].a, vc[i].b);
            K /= 3;
        }
        sort(vc.begin(),vc.end());
        for(i = 0; i < N; ++i){
            dp[i] = vc[i].c;
            for(j = 0; j < i; ++j){
                if(vc[j].a <= vc[i].a && vc[j].b <= vc[i].b){
                    dp[i] = std::max(dp[i], dp[j] + vc[i].c);
                }
            }
            if(ans < dp[i]) ans = dp[i];
        }
    }
    std::cout << ans << std::endl;
}
0