結果

問題 No.1541 ゅゅさんのテスト勉強
ユーザー logxlogx
提出日時 2021-05-23 12:26:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,645 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 88,820 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-19 20:29:44
合計ジャッジ時間 4,698 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 5 ms
6,944 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

struct input_structure{
    int n;
    long long m;
    std::vector<int> k;
    std::vector<std::vector<int>> A;
    std::vector<std::vector<long long>> B;
    std::vector<long long> C;
    input_structure(){
        std::cin >> n >> m;
        k.resize(n);
        A.resize(n);
        B.resize(n);
        C.resize(n);
        for(int i=0;i<n;i++){
            std::cin >> k[i] >> C[i];
            A[i].resize(k[i]);
            B[i].resize(k[i]);
            for(int j=0;j<k[i];j++)std::cin >> A[i][j];
            for(int j=0;j<k[i];j++)std::cin >> B[i][j];
        }
    }
    friend std::ostream& operator<<(std::ostream &os,input_structure &in){
        std::cout << in.n << ' ' << in.m << '\n';
        for(int i=0;i<in.n;i++){
            std::cout << in.k[i] << ' ' << in.C[i] << '\n';
            for(int j=0;j<in.k[i];j++)std::cout << in.A[i][j] << (j+1==in.k[i] ? "\n":" ");
            for(int j=0;j<in.k[i];j++)std::cout << in.B[i][j] << (j+1==in.k[i] ? "\n":" ");
        }
        return os;
    }
};

//愚直解. O(2^N * sum(k)) なので O(2^N * N^2).
long long solve_greedy(input_structure in){
    for(auto &vec:in.A)for(int &idx:vec)idx--;
    long long ans=0;//自明に0以上にはできる.
    for(int S=0;S<(1<<in.n);S++){
        long long now=0;
        for(int i=0;i<in.n;i++)if(S>>i & 1){
            now+=in.m-in.C[i];
            for(int j=0;j<in.k[i];j++){
                if(S>>in.A[i][j] & 1)now+=in.B[i][j];
            }
        }
        ans=std::max(ans,now);
    }
    return ans;
}

int main(){
    input_structure in;
    std::cout << solve_greedy(in) << '\n';
}
0