Submission #3003870
Source Code Expand
#include <iostream> #include <string> #include <queue> #include <vector> #include <set> #include <map> #include <algorithm> #include <utility> #include <iomanip> #define ll long long int #define pb push_back #define mk make_pair #define pq priority_queue using namespace std; typedef pair<int, int> P; typedef pair<ll, int> Pl; const int inf = 1e9; const ll linf = 1LL << 50; int n; ll a[2001]; ll dp[2001][2001]; ll dp2[2001][2001]; ll sum[2001]; ll k; int main(int argc, char const* argv[]) { cin >> n >> k; for(int i = 0; i < n; i++)cin >> a[i]; sum[0] = a[0]; for(int i = 1; i < n; i++)sum[i] = sum[i-1] + a[i]; for(int i = 0; i <= n; i++){ for(int j = 0; j <= k; j++){ dp[i][j] = linf; } } for(int i = 0; i <= n; i++){ for(int j = 0; j <= k; j++){ dp2[i][j] = -1 * linf / 2; } } dp[0][0] = 0; for(int i = 0; i < n; i++){ dp[i+1][0] = 0; for(int j = 1; j <= i+1; j++){ dp[i+1][j] = dp[i][j]; if(dp[i][j-1] >= linf)continue; ll ww; if(i != 0){ ww = (ll)(a[i] * dp[i][j-1] / sum[i-1]) + 1; }else{ ww = 1; } if(ww <= a[i])dp[i+1][j] = min(dp[i+1][j], dp[i][j-1] + ww); } } dp2[0][0] = 0; for(int i = 0; i < n; i++){ dp2[i+1][0] = 0; for(int j = 1; j <= i+1; j++){ dp2[i+1][j] = dp2[i][j]; if(dp2[i][j] >= 0){ ll tmp = a[0]; if(i != 0)tmp = (a[i] * dp2[i][j] / sum[i-1]); dp2[i+1][j] += min(a[i], tmp); } if(i != 0 && dp2[i][j-1] != sum[i-1])dp2[i+1][j] = max(dp2[i+1][j], dp2[i][j-1] + a[i]); else if(i != 0 && dp[i][j-1] < linf)dp2[i+1][j] = max(dp2[i+1][j], dp2[i][j-1] + a[i] - 1); if(i == 0)dp2[i+1][j] = a[i]; } } ll res = 0; for(int i = 1; i <= n; i++){ if(dp[n][i] <= k && dp2[n][i] >= k)res = i; } cout << res << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - 高橋君ゲーム |
User | fumiphys |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1885 Byte |
Status | RE |
Exec Time | 717 ms |
Memory | 62848 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | RE | 110 ms | 32128 KB |
02.txt | WA | 65 ms | 62336 KB |
03.txt | WA | 63 ms | 61440 KB |
04.txt | AC | 74 ms | 62848 KB |
05.txt | WA | 63 ms | 61440 KB |
06.txt | AC | 75 ms | 62848 KB |
07.txt | RE | 110 ms | 32128 KB |
08.txt | RE | 110 ms | 32128 KB |
09.txt | RE | 111 ms | 32128 KB |
10.txt | WA | 63 ms | 61440 KB |
11.txt | WA | 65 ms | 62336 KB |
12.txt | AC | 75 ms | 62848 KB |
13.txt | WA | 66 ms | 62720 KB |
14.txt | RE | 105 ms | 32128 KB |
15.txt | AC | 69 ms | 62848 KB |
16.txt | RE | 106 ms | 32128 KB |
17.txt | RE | 158 ms | 32128 KB |
18.txt | RE | 114 ms | 32128 KB |
19.txt | RE | 149 ms | 32128 KB |
20.txt | WA | 63 ms | 61696 KB |
21.txt | RE | 107 ms | 32128 KB |
22.txt | RE | 105 ms | 32128 KB |
23.txt | WA | 74 ms | 62848 KB |
24.txt | AC | 75 ms | 62848 KB |
25.txt | RE | 107 ms | 32128 KB |
26.txt | RE | 106 ms | 32128 KB |
27.txt | RE | 106 ms | 32128 KB |
28.txt | RE | 106 ms | 32128 KB |
29.txt | WA | 64 ms | 61952 KB |
30.txt | RE | 715 ms | 32128 KB |
31.txt | RE | 111 ms | 32128 KB |
32.txt | RE | 106 ms | 32128 KB |
33.txt | RE | 121 ms | 32128 KB |
34.txt | WA | 63 ms | 61440 KB |
35.txt | RE | 106 ms | 32128 KB |
36.txt | WA | 66 ms | 62720 KB |
37.txt | WA | 67 ms | 62848 KB |
38.txt | WA | 64 ms | 61824 KB |
39.txt | WA | 66 ms | 62720 KB |
40.txt | WA | 63 ms | 61440 KB |
41.txt | WA | 66 ms | 62720 KB |
42.txt | RE | 112 ms | 32128 KB |
43.txt | WA | 64 ms | 62080 KB |
44.txt | RE | 716 ms | 32128 KB |
45.txt | RE | 715 ms | 32128 KB |
46.txt | RE | 717 ms | 32128 KB |
47.txt | WA | 63 ms | 61312 KB |
48.txt | WA | 63 ms | 61312 KB |
49.txt | WA | 63 ms | 61440 KB |
50.txt | WA | 63 ms | 61440 KB |
51.txt | AC | 2 ms | 2304 KB |
52.txt | WA | 2 ms | 2304 KB |
53.txt | AC | 2 ms | 2304 KB |
54.txt | AC | 2 ms | 2304 KB |
55.txt | WA | 2 ms | 2304 KB |
56.txt | AC | 2 ms | 2304 KB |
57.txt | AC | 2 ms | 2304 KB |
58.txt | WA | 2 ms | 2304 KB |
59.txt | WA | 2 ms | 2304 KB |
60.txt | WA | 2 ms | 2304 KB |
61.txt | WA | 2 ms | 2304 KB |
62.txt | AC | 2 ms | 2304 KB |
63.txt | AC | 4 ms | 10496 KB |
64.txt | WA | 2 ms | 2304 KB |
s1.txt | AC | 2 ms | 2304 KB |
s2.txt | AC | 2 ms | 2304 KB |
s3.txt | AC | 2 ms | 2304 KB |
s4.txt | AC | 2 ms | 2304 KB |