QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#392996#6326. Make Convex SequenceGiga_Cronos#WA 34ms7392kbC++231.2kb2024-04-18 02:11:492024-04-18 02:11:50

Judging History

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

  • [2024-04-18 02:11:50]
  • 评测
  • 测评结果:WA
  • 用时:34ms
  • 内存:7392kb
  • [2024-04-18 02:11:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN   ((ll)(1e5 + 5))
#define pb     push_back
#define sz     size
#define all(x) x.begin(), x.end()
#define ld long double
#define vi vector<int>

int n;
vi a,b;


ld slope(int i,int j){
    return (ld)((ld)b[j]-b[i])/((ld)j-i);
}

void solve(){
    cin>>n;

    for(int i=0;i<n;i++){
        int x;cin>>x;
        a.pb(x);
    }
    
    for(int i=0;i<n;i++){
        int x;cin>>x;
        b.pb(x);
    }

    vi v;
    for(int i=0;i<n;i++){
        if(!v.sz()){ 
            v.pb(i);
            continue;
        }
        while(v.sz()>=2 && slope(v[v.sz()-1],v[v.sz()-2]) > slope(i,v[v.sz()-2])){
            v.pop_back();
        }
        v.pb(i);
    }

    bool can=true;

    for(int i=1;i<v.sz();i++){
        ld slop=slope(v[i-1],v[i]);
        ld wr=b[i-1];
        for(int j=v[i-1]+1;j<v[i];j++){
            wr+=slop;
            if(a[j]>wr){
                can=false;
            }
        }
    }

    if(can){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
2 1 2 5
4 6 5 8

output:

YES

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

3
1 4 2
3 7 4

output:

NO

result:

ok answer is NO

Test #3:

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

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