結果

問題 No.1288 yuki collection
ユーザー kyort0nkyort0n
提出日時 2020-11-13 22:02:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,385 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 191,680 KB
実行使用メモリ 4,824 KB
最終ジャッジ日時 2023-09-30 02:54:01
合計ジャッジ時間 6,141 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 97 ms
4,700 KB
testcase_14 AC 101 ms
4,652 KB
testcase_15 AC 77 ms
4,432 KB
testcase_16 AC 79 ms
4,708 KB
testcase_17 AC 102 ms
4,660 KB
testcase_18 WA -
testcase_19 AC 100 ms
4,684 KB
testcase_20 AC 109 ms
4,660 KB
testcase_21 AC 126 ms
4,644 KB
testcase_22 AC 125 ms
4,748 KB
testcase_23 AC 125 ms
4,644 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 54 ms
4,648 KB
testcase_28 AC 64 ms
4,624 KB
testcase_29 WA -
testcase_30 AC 7 ms
4,696 KB
testcase_31 AC 10 ms
4,656 KB
testcase_32 AC 11 ms
4,660 KB
testcase_33 AC 95 ms
4,656 KB
testcase_34 AC 130 ms
4,624 KB
testcase_35 AC 116 ms
4,664 KB
testcase_36 AC 65 ms
4,664 KB
testcase_37 AC 68 ms
4,656 KB
testcase_38 AC 83 ms
4,660 KB
testcase_39 AC 40 ms
4,636 KB
testcase_40 AC 4 ms
4,680 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/mincostflow>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
string S;
vector<ll> V;
ll ans = 0;
vector<ll> s;
string yuki = "yuki";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    V.resize(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    ll s = 4 * N;
    ll t = s + 1;
    atcoder::mcf_graph<ll, ll> g(t + 1);
    g.add_edge(s, 0, N, 0);
    for(int i = 0; i + 1 < N; i++) {
        for(int j = 0; j < 4; j++) {
            g.add_edge(4 * i + j, 4 * (i + 1) + j, N, 0);
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 4; j++) {
            if(S[i] != yuki[j]) continue;
            if(j != 3) {
                g.add_edge(4*i+j, 4*i+j+1, 1, (ll)1e9 - V[i]);
            } else {
                g.add_edge(4*i+j, t, 1, (ll)1e9 - V[i]);
            }
        }
    }
    l_l tmp = g.flow(s, t);
    ll ans = tmp.first * (ll)1e9 * 4 - tmp.second;
    cout << ans << endl;
    return 0;
}
0