結果
| 問題 |
No.1029 JJOOII 3
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2020-04-20 01:55:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 974 bytes |
| コンパイル時間 | 2,809 ms |
| コンパイル使用メモリ | 197,080 KB |
| 最終ジャッジ日時 | 2025-01-09 21:50:08 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 TLE * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
int main()
{
int N, K;
cin >> N >> K;
vector<string> S(N);
vector<lint> C(N);
REP(i, N) cin >> S[i] >> C[i];
vector<lint> cost(K * 3 + 1, 9e18);
cost[0] = 0;
REP(i, K * 3) if (cost[i] < cost[i + 1])
{
REP(j, N)
{
int now = i;
for (auto c : S[j])
{
if (now < K and c == 'J') now++;
if (now >= K and now < K * 2 and c == 'O') now++;
if (now >= K * 2 and now < K * 3 and c == 'I') now++;
}
cost[now] = min(cost[now], cost[i] + C[j]);
}
}
cout << (cost.back() == 9e18 ? -1 : cost.back()) << '\n';
}
hitonanode