QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#240435 | #4931. Comic Binge | NYCU_gAwr_gurA# | WA | 1ms | 3412kb | C++20 | 1.4kb | 2023-11-05 15:28:20 | 2023-11-05 15:28:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define cerr if(1);else cerr
#define endl '\n'
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
constexpr int MAXN = 1000;
constexpr int MAXB = 10;
constexpr int MAXT = MAXB * MAXN;
void chmax(auto& a, auto b) {
if (a < b) a = b;
}
signed main() {
fast;
int n;
cin >> n;
vector<int> A(n), B(n);
for (auto &x: A) cin >> x;
for (auto &x: B) cin >> x;
int T = accumulate(ALL(B), 0);
vector<int> dp(T*2+1, -1);
for (int i = 0; i < n; i++) {
for (int t = T; t >= 0; t--)
if (dp[t] == i-1 or dp[t] == i-2)
chmax(dp[t+B[i]], i);
}
for (int t = T; t > 0; t--)
if (dp[t-1] == dp[t]-2) {
int i = dp[t];
for (int j = 1; j < B[i] and t-j >= 0; j++)
chmax(dp[t-j], i-1);
}
for (int t = 0; t <= T; t++)
cerr << setw(2) << 1+t << " \n"[t==T];
for (int t = 0; t <= T; t++)
cerr << setw(2) << 1+dp[t] << " \n"[t==T];
int time = 0;
for (int i = 0; i < n; i++) {
while (time < T and dp[time] < i)
time++;
cerr _ i+1 _ A[i] _ time+1 _ endl;
time += A[i];
}
cout << time << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3412kb
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: 1ms
memory: 3412kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3392kb
input:
1 1 1
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3396kb
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:
80579
result:
wrong answer 1st lines differ - expected: '80587', found: '80579'