結果
| 問題 |
No.1288 yuki collection
|
| ユーザー |
kyort0n
|
| 提出日時 | 2020-11-13 22:02:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,385 bytes |
| コンパイル時間 | 2,273 ms |
| コンパイル使用メモリ | 195,028 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-22 20:50:59 |
| 合計ジャッジ時間 | 5,860 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 WA * 5 |
ソースコード
#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;
}
kyort0n