QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#213545#6326. Make Convex Sequencepengpeng_fudanWA 29ms7024kbC++14937b2023-10-14 14:47:322023-10-14 14:47:33

Judging History

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

  • [2023-10-14 14:47:33]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:7024kb
  • [2023-10-14 14:47:32]
  • 提交

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&&(s[i][1]-s[st[i]][1])*(st[i]-st[i-1])<(s[st[i]][1]-s[st[i]-1][1]*(i-st[i])))    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];
    build();
    int l=1;
    for(int i=2;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: 1ms
memory: 5708kb

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

input:

3
1 4 2
3 7 4

output:

No

result:

ok answer is NO

Test #3:

score: -100
Wrong Answer
time: 29ms
memory: 7024kb

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