結果

問題 No.2713 Just Solitaire
コンテスト
ユーザー tatesoto
提出日時 2026-10-25 05:38:47
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 61µs
コード長 4,153 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,949 ms
コンパイル使用メモリ 381,388 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-25 05:38:56
合計ジャッジ時間 7,175 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) {
    return is >> p.first >> p.second;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
    for(auto& x : v) is >> x;
    return is;
}
template<class... T> void in(T&... a) {
    (cin >> ... >> a);
}

template<class T, class U> ostream& operator<<(ostream& o, const pair<T, U>& p) {
    o << p.first << " " << p.second;
    return o;
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
    int i = 0;
    for(const auto& x : v) o << (i++ ? " " : "") << x;
    return o;
}
template<class T> ostream& operator<<(ostream& o, const vector<vector<T>>& v) {
    int i = 0;
    for(const auto& x : v) o << (i++ ? "\n" : "") << x;
    return o;
}
inline void out() {
    cout << "\n";
}
template<class H, class... T> void out(const H& h, const T&... t) {
    cout << h;
    ((cout << " " << t), ...);
    cout << "\n";
}
#ifndef ONLINE_JUDGE
#if __has_include(<cpp-dump.hpp>)
#include <cpp-dump.hpp>
#define dump(...) cpp_dump(__VA_ARGS__)
namespace cp = cpp_dump;
CPP_DUMP_SET_OPTION_GLOBAL(max_line_width, 120);
CPP_DUMP_SET_OPTION_GLOBAL(log_label_func, cp::log_label::filename());
#else
#define dump(x) cerr << #x << " = " << (x) << '\n'
#endif
#else
#define dump(...) (void)0
#define CPP_DUMP_SET_OPTION(...)
#define CPP_DUMP_DEFINE_EXPORT_OBJECT(...)
#define CPP_DUMP_DEFINE_EXPORT_OBJECT_GENERIC(...)
#define CPP_DUMP_DEFINE_EXPORT_ENUM(...)
#define CPP_DUMP_DEFINE_EXPORT_ENUM_GENERIC(...)
#endif
using ll = long long;
using ld = long double;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define OVERLOAD_REP(_1,_2,_3,name,...) name
#define REP1(i,n) for (ll i = 0; (i) < (ll)(n); ++(i))
#define REP2(i, l, r) for (ll i = (ll)(l); (i) < (ll)(r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define RREP1(i, n) for (ll i = (ll)(n)-1; i>=0; --i)
#define RREP2(i, l, r) for (ll i = (ll)(r)-1; i>=(ll)(l); --i)
#define rrep(...) OVERLOAD_REP(__VA_ARGS__, RREP2, RREP1)(__VA_ARGS__)
#define sz(a) ssize((a))
template<class T, class U> inline bool chmin(T& a, const U& b) {if(a > b){a = b; return true;} else {return false;}}
template<class T, class U> inline bool chmax(T& a, const U& b) {if(a < b){a = b; return true;} else {return false;}}
template<class T, class U> inline bool inLR(const T& x, const U& n) {return 0 <= x && x < n;}
template<class T, class U, class V> inline bool inLR(const T& x, const U& l, const V& r) {return l <= x && x < r;}
template<class T, class U, class V, class W> inline bool inGrid(const T& i, const U& j, const V& h, const W& w) {return inLR(i, h) && inLR(j, w);}
inline void Yes(bool ok = true) {cout << (ok ? "Yes" : "No") << "\n";}
inline void No() {cout << "No\n";}
inline void YES(bool ok = true) {cout << (ok ? "YES" : "NO") << "\n";}
inline void NO() {cout << "NO\n";}
template<class T, class U> inline auto ceil(T a, U b) {return (a + b - 1) / b;}
const ll INF=(1LL<<60);
const ll mod=998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {1, 1,  1, 0,  0, -1, -1, -1};
const int dy2[8] = {1, 0, -1, 1, -1,  1,  0, -1};
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using pll = pair<ll,ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
template <class T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

void solve() {
    ll n, m;in(n, m);
    vll a(n), b(m);in(a, b);
    mf_graph<ll> mf(n+m+2);
    const ll S = n+m, T = n+m+1;
    ll sm = 0;
    rep(i, n) {
        mf.add_edge(i, T, a[i]);
    }
    rep(i, m) {
        ll k;in(k);
        sm += b[i];
        mf.add_edge(S, n+i, b[i]);
        rep(j, k) {
            ll c;in(c);c--;
            mf.add_edge(n+i, c, INF);
        }
    }
    out(sm-mf.flow(S, T));
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
0