QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133453#4931. Comic Bingenameless_story#RE 1ms3604kbC++17900b2023-08-02 09:37:292023-08-02 09:37: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 09:37:32]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3604kb
  • [2023-08-02 09:37:29]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define N 30000

int a[N],b[N],f[N],sa[N];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;   
    for (int i=1;i<=n;++i){
        cin>>a[i];
        sa[i]=sa[i-1]+a[i];
    }
    for (int i=1;i<=n;++i){
        cin>>b[i];
    }
    int mx=sa[n]+n*10;
    int l=b[1]+sa[n],r=mx;
    int ans=0;
    auto check=[&](int k){
        f[0]=k+1; f[1]=b[1];
        f[n]=k+1;
        for (int i=2;i<=n;++i){
            f[i]=min(f[i-1],f[i-2])+b[i];
            if (f[i]+sa[n]-sa[i-1]>k) f[i]=k+1;
            if (f[i]==k+1&&f[i-1]==k+1) return 0;
        }
        return int(f[n]<=k);
    };
    while (l<=r){
        int mid=(l+r)>>1;
        if (check(mid)){
            ans=mid; r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    assert(ans>0);
    cout<<ans<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

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: 3480kb

input:

2
2 1
1 1

output:

4

result:

ok single line: '4'

Test #3:

score: -100
Dangerous Syscalls

input:

1
1
1

output:


result: