QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133499 | #4931. Comic Binge | Rd_rainydays# | WA | 1ms | 3872kb | C++14 | 856b | 2023-08-02 10:13:30 | 2023-08-02 10:13:32 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;++i)
static const int M=1003;
int n,A[M],B[M];
int F[4][10003];
void chkmin(int &x,int y){
if(x>y)x=y;
}
int main(){
scanf("%d",&n);
REP(i,0,n)scanf("%d",&A[i]);
REP(i,0,n)scanf("%d",&B[i]);
memset(F,0x3f,sizeof(F));
F[0][0]=0;
int f=0;int s=0;
REP(i,0,n){
REP(j,0,s+1)if(F[f][j]!=0x3f3f3f3f){
int t=F[f][j];F[f][j]=0x3f3f3f3f;
chkmin(F[(f+1)&3][j+B[i]],max(j+B[i],t)+A[i]);
chkmin(F[(f+2)&3][j+B[i+1]],max(j+B[i+1],t+A[i])+A[i+1]);
//cerr<<i<<','<<j<<','<<t<<endl;
}
f=(f+1)&3;
s+=B[i];
}
int Ans=0x3f3f3f3f;
REP(i,0,10003)Ans=min(Ans,max(i,F[f][i]));
printf("%d\n",Ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3804kb
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: 3872kb
input:
2 2 1 1 1
output:
3
result:
wrong answer 1st lines differ - expected: '4', found: '3'