QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#753861 | #4931. Comic Binge | MeatInTheMiddle# | WA | 12ms | 145720kb | C++17 | 1.5kb | 2024-11-16 13:45:21 | 2024-11-16 13:45:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fastio (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
typedef long long ll;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int MAXSIZE = 2000000;
const long long INF = 1e9 + 5;
const double EPSILON = 1e-14;
const ll DIV = 2000003;
const long double pi = 3.14159265358979323846264338327950288419716939937510L;
int n;
int dp[1005][1005][12][3];
int A[1005], B[1005];
int psum[1005];
pair<int, int> find(int l, int r, int tm, int rem)
{
for (int i = l; i < r; i++)
{
if (A[i] <= rem + tm)
{
tm = 0;
rem -= A[i] - tm;
}
else
{
return {i, rem};
}
}
return {r, 0};
}
int solve(int l, int r, int tm, int c)
{
if (r == n + 1)
return psum[n] - psum[l - 1] - tm;
int &ret = dp[l][r][tm][c];
if (ret != -1)
return ret;
ret = INF;
if (c == 1)
{
ret = min(ret, solve(l, r + 1, tm, 0));
}
auto p = find(l, r, tm, B[r]);
ret = min(ret, solve(p.first, r + 1, p.second, 1) + B[r]);
return ret;
}
int main()
{
fastio;
memset(dp, -1, sizeof dp);
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> A[i];
psum[i] = psum[i - 1] + A[i];
}
for (int i = 1; i <= n; i++)
{
cin >> B[i];
}
cout << solve(1, 1, 0, 0);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 145692kb
input:
6 3 1 1 1 1 2 1 5 3 3 7 4
output:
13
result:
ok single line: '13'
Test #2:
score: 0
Accepted
time: 3ms
memory: 145704kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 3ms
memory: 145648kb
input:
1 1 1
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 4ms
memory: 145720kb
input:
161 146 662 336 441 626 77 362 697 911 248 879 40 435 60 518 62 475 908 185 740 435 899 188 673 716 529 524 305 321 998 4 363 598 471 650 379 6 980 971 175 664 328 294 681 201 64 926 608 310 478 404 284 634 239 891 515 433 368 929 457 593 338 432 971 593 134 355 97 658 344 653 592 822 660 403 398 38...
output:
80923
result:
wrong answer 1st lines differ - expected: '80587', found: '80923'