Submission #00247
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include<bits/stdc++.h> using namespace std; struct data { int weight, hate, big; }; typedef long long int64; const int INF = 1LL << 55; int64 power[50], dp[100][50]; int64 calc( int idx, vector< data >& d, int st) { if (idx == d.size()) return (0); if (~dp[idx][st]) return (dp[idx][st]); int64 ret = INF; for ( int i = 0; i <= d[idx].weight && i <= st; i++) { int64 next = calc(idx + 1, d, st - i); int64 cost = power[d[idx].weight - i + 1] * power[d[idx].hate + 1]; if (cost <= d[idx].big && next >= 0) { if (i == d[idx].weight) cost = 0; ret = min(ret, next + cost); } } if (ret >= INF) return (dp[idx][st] = INF); else return (dp[idx][st] = ret); } int main() { int need[2]; vector< data > d[2]; for (int64 i = 0, d = 1; i < 50; d *= 2, i++) { power[i] = d; } cin >> need[0] >> need[1]; for ( int i = 0; i < 5; i++) { string kind; int w, hate, big; cin >> kind >> w >> hate >> big; d[kind == "orange" ].push_back((data){w, hate, big}); } fill_n(*dp, 100 * 50, -1); int64 a = calc(0, d[0], need[0]); fill_n(*dp, 100 * 50, -1); int64 b = calc(0, d[1], need[1]); if (a < INF && b < INF) { cout << a + b << endl; } else { cout << "Hello!" << endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0015 - あふたぬーんてぃー |
ユーザー名 | ei1333 |
投稿日時 | 2015-05-27 17:42:38 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1299 Byte |
最大実行時間 | 13 ms |
最大メモリ使用量 | 704 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 30 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
Alice_in1.txt | WA | 11 ms | 704 KB |
1
|
Alice_in2.txt | AC | 10 ms | 656 KB |
1
|
Alice_in3.txt | AC | 13 ms | 604 KB |
1
|
Alice_in4.txt | WA | 10 ms | 688 KB |
1
|
Alice_in5.txt | WA | 10 ms | 512 KB |
1
|