QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133499#4931. Comic BingeRd_rainydays#WA 1ms3872kbC++14856b2023-08-02 10:13:302023-08-02 10:13:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 10:13:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3872kb
  • [2023-08-02 10:13:30]
  • 提交

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'