結果

問題 No.2713 Just Solitaire
ユーザー nononnonon
提出日時 2024-03-31 14:54:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 4,141 ms
コンパイル使用メモリ 213,492 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:55:10
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/maxflow>
using namespace std;
int N,M,A[100],B[100],K[100];
bool bad[100][100];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>M;
    for(int i=0;i<N;i++)cin>>A[i];
    for(int j=0;j<M;j++)cin>>B[j];
    for(int i=0;i<M;i++)
    {
        cin>>K[i];
        for(int j=0;j<K[i];j++)
        {
            int c;
            cin>>c;
            bad[i][c-1]=1;
        }
    }
    atcoder::mf_graph<long>G(N+M+2);
    for(int i=0;i<N;i++)
    {
        G.add_edge(N+M+1,M+i,A[i]);
    }
    long sum=0;
    for(int i=0;i<M;i++)
    {
        G.add_edge(i,M+N,B[i]);
        sum+=B[i];
    }
    for(int i=0;i<M;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(bad[i][j])G.add_edge(j+M,i,1L<<50);
            else G.add_edge(i,j+M,0);
        }
    }
    cout<<sum-G.flow(N+M+1,N+M)<<endl;
    // for(auto e:G.edges())cout<<e.cap<<' '<<e.flow<<endl;
}
0