QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#213514#6326. Make Convex Sequencepengpeng_fudanWA 34ms5796kbC++14942b2023-10-14 14:38:562023-10-14 14:38:57

Judging History

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

  • [2023-10-14 14:38:57]
  • 评测
  • 测评结果:WA
  • 用时:34ms
  • 内存:5796kb
  • [2023-10-14 14:38:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ll=long long;
int s[300010][2];
int op;
int n;
int st[300010];
void build(){
    op++;
    st[1]=1;
    for(int i=2;i<=n;i++){
        while(op!=1&&2*s[st[op]][1]>s[st[op-1]][1]+s[i][1])    op--;
        st[++op]=i;
    }
}
void solve() {
    cin>>n;
    for(int i=1;i<=n;i++)   cin>>s[i][0];
    for(int i=1;i<=n;i++)   cin>>s[i][1];
    s[0][0]=s[0][1]=1e9+10;
    build();
    st[0]=0;
    int l=1;
    for(int i=1;i<=n;i++){
        if(i>st[l])    l++;
        ll b=s[st[l-1]][1],a=s[st[l]][1];
        int l1=st[l-1],l2=st[l];
        if(1ll*(a-b)*(i-l1)>=1ll*(s[i][0]-b)*(l2-l1));
        else{
            cout<<"No"<<'\n';
            return ;
        }
    }
    cout<<"Yes"<<'\n';
}
int main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int _ = 1;
    //cin >> _;
    while(_--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3728kb

input:

4
2 1 2 5
4 6 5 8

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 1ms
memory: 5648kb

input:

3
1 4 2
3 7 4

output:

No

result:

ok answer is NO

Test #3:

score: -100
Wrong Answer
time: 34ms
memory: 5796kb

input:

271757
150678576 28436211 82026915 150751377 329329758 207446456 449759844 245730845 425844298 93416110 220240900 414108016 268705922 158510126 362264528 715921 468258085 104286815 63874786 73971103 476243636 89261247 440888454 422989962 422041006 436065809 498263669 368104872 458751340 280953952 40...

output:

Yes

result:

wrong answer expected NO, found YES