結果
| 問題 |
No.1029 JJOOII 3
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2020-04-20 01:53:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,017 bytes |
| コンパイル時間 | 2,982 ms |
| コンパイル使用メモリ | 197,072 KB |
| 最終ジャッジ日時 | 2025-01-09 21:49:21 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 TLE * 15 |
ソースコード
#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] == 9e18)
{
puts("-1");
return 0;
}
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() << '\n';
}
hitonanode