QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133434 | #4931. Comic Binge | Delay_for_five_minutes# | WA | 1ms | 3592kb | C++20 | 1.0kb | 2023-08-02 09:26:21 | 2023-08-02 09:26:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1005] , b[1005];
int f[3][10005];
void upd(int &x,int y)
{
x = min(x , y);
}
int main()
{
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++) {cin >> b[i]; a[i] += a[i - 1];}
int cur = 0;
memset(f,127,sizeof(f));
f[0][0] = 0;
int s = 0;
for(int i = 0;i < n;i++) {
for(int j = 0;j <= s;j++) {
// printf("%d %d ,. %d\n",i,j,f[cur][j]);
upd(f[(cur + 1) %3][j + b[i + 1]] , max(f[cur][j] , j + b[i + 1] - a[i]) ) ;
if(i + 2 <= n) upd(f[(cur + 2) % 3][j + b[i + 2]] , max(f[cur][j] , j + b[i + 2] - a[i + 1]));
}
s += b[i + 1];
memset(f[cur] , 127 , sizeof(f[cur]));
cur = (cur + 1) % 3;
}
s += b[n];
int ans = 1e9;
for(int j = 0 ; j <= s;j++) ans = min(ans , f[cur][j]);
cout << a[n] + ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
6 3 1 1 1 1 2 1 5 3 3 7 4
output:
13
result:
ok single line: '13'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3552kb
input:
2 2 1 1 1
output:
3
result:
wrong answer 1st lines differ - expected: '4', found: '3'