結果

問題 No.1288 yuki collection
ユーザー chocoruskchocorusk
提出日時 2021-02-21 00:32:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4,175 ms / 5,000 ms
コード長 1,316 bytes
コンパイル時間 4,178 ms
コンパイル使用メモリ 205,596 KB
実行使用メモリ 116,932 KB
最終ジャッジ日時 2023-10-19 03:12:24
合計ジャッジ時間 38,789 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 956 ms
60,448 KB
testcase_14 AC 1,077 ms
60,184 KB
testcase_15 AC 654 ms
49,164 KB
testcase_16 AC 698 ms
49,956 KB
testcase_17 AC 1,068 ms
59,920 KB
testcase_18 AC 1,068 ms
60,184 KB
testcase_19 AC 1,014 ms
59,656 KB
testcase_20 AC 1,190 ms
61,964 KB
testcase_21 AC 2,302 ms
90,864 KB
testcase_22 AC 2,285 ms
90,864 KB
testcase_23 AC 2,273 ms
90,404 KB
testcase_24 AC 1,097 ms
60,976 KB
testcase_25 AC 1,040 ms
61,272 KB
testcase_26 AC 1,134 ms
60,976 KB
testcase_27 AC 339 ms
33,600 KB
testcase_28 AC 527 ms
48,644 KB
testcase_29 AC 447 ms
53,592 KB
testcase_30 AC 98 ms
58,404 KB
testcase_31 AC 120 ms
59,920 KB
testcase_32 AC 128 ms
58,140 KB
testcase_33 AC 3,003 ms
116,932 KB
testcase_34 AC 1,625 ms
63,020 KB
testcase_35 AC 1,394 ms
60,184 KB
testcase_36 AC 866 ms
60,712 KB
testcase_37 AC 935 ms
60,712 KB
testcase_38 AC 4,175 ms
116,872 KB
testcase_39 AC 1,497 ms
116,872 KB
testcase_40 AC 69 ms
57,152 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int n;
string str;
ll v[3030];
int main()
{
    cin>>n;
    cin>>str;
    for(int i=0; i<n; i++) cin>>v[i];
	int s=2*n, t=2*n+1;
    mcf_graph<ll, ll> g(2*n+2);
    const ll INF=1e9+7;
    for(int i=0; i<n; i++){
        if(str[i]=='y') g.add_edge(s, 2*i, 1, 0);
        g.add_edge(2*i, 2*i+1, 1, INF-v[i]);
        if(str[i]=='i') g.add_edge(2*i+1, t, 1, 0);
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<i; j++){
            if((str[j]=='y' && str[i]=='u') || (str[j]=='u' && str[i]=='k') || (str[j]=='k' && str[i]=='i')){
                g.add_edge(2*j+1, 2*i, 1, 0);
            }
        }
    }
    g.add_edge(s, t, n/4, INF*4);
    cout<<INF*(n/4)*4-g.flow(s, t, n/4).second<<endl;
    return 0;
}
0