結果

問題 No.1288 yuki collection
ユーザー yurujirouyurujirou
提出日時 2021-10-10 23:22:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,601 bytes
コンパイル時間 3,724 ms
コンパイル使用メモリ 189,580 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 21:17:45
合計ジャッジ時間 6,728 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,480 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 40 ms
4,348 KB
testcase_14 AC 42 ms
4,348 KB
testcase_15 AC 32 ms
4,352 KB
testcase_16 AC 33 ms
4,352 KB
testcase_17 AC 42 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 41 ms
4,348 KB
testcase_20 AC 45 ms
4,348 KB
testcase_21 AC 49 ms
4,352 KB
testcase_22 AC 50 ms
4,348 KB
testcase_23 AC 49 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 23 ms
4,348 KB
testcase_28 AC 27 ms
4,352 KB
testcase_29 WA -
testcase_30 AC 6 ms
4,348 KB
testcase_31 AC 7 ms
4,348 KB
testcase_32 AC 7 ms
4,348 KB
testcase_33 AC 39 ms
4,352 KB
testcase_34 AC 48 ms
4,348 KB
testcase_35 AC 41 ms
4,348 KB
testcase_36 AC 23 ms
4,348 KB
testcase_37 AC 24 ms
4,352 KB
testcase_38 AC 30 ms
4,352 KB
testcase_39 AC 22 ms
4,348 KB
testcase_40 AC 5 ms
4,348 KB
testcase_41 AC 1 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <functional>
#include <math.h>
#include <complex>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define RREP(i,n) for(int i = (int)n-1; i >= 0; i--)
#define LREP(i,n) for(LL i = 0; i < (LL)n; i++)

#define Vi vector<int>
#define Vl vector<long long>
#define LP pair<long long ,long long>
#define P pair<int, int>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE	400010
#define MOD 998244353
typedef long long LL;

LL N;
string S;
LL V[SIZE];

int main() {
	cin >> N >> S;
	REP(i, N) cin >> V[i];

	LL X = INF;
	mcf_graph<LL, LL> graph(N + 2);
	string T = "yuki";
	REP(k, 4) {
		REP(i, N) {
			if (S[i] == T[k]) {
				REP(j, N) {
					if (j <= i) continue;
					if (S[j] == T[k]) {
						graph.add_edge(i, j, SIZE, 0);
						break;
					}
				}
			}
		}
	}
	REP(i, N) {
		if (S[i] == 'y') {
			graph.add_edge(N, i, SIZE, 0);
			break;
		}
	}

	REP(k, 3) {
		REP(i, N) {
			if (S[i] == T[k]) {
				REP(j, N) {
					if (j <= i) continue;
					if (S[j] == T[k + 1]) {
						graph.add_edge(i, j, 1, X - V[i]);
						break;
					}
				}
			}
		}
	}

	REP(i, N) {
		if (S[i] == 'i') {
			graph.add_edge(i, N + 1, 1, X - V[i]);
		}
	}

	LP res = graph.flow(N, N + 1);
	cout << -(res.second - 4 * X * res.first) << endl;
}
0