QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393014#6326. Make Convex SequenceGiga_Cronos#WA 30ms7380kbC++231.6kb2024-04-18 03:14:302024-04-18 03:14:31

Judging History

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

  • [2024-04-18 03:14:31]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:7380kb
  • [2024-04-18 03:14:30]
  • 提交

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);
}

#define ii pair<int,int>
#define fs first
#define sc second

int cross(ii a,ii b){
    return a.fs*b.sc-a.sc*b.fs;
}


int tc(int  i,int j,int k){
    ii p1={j,b[j]};
    ii p2={k,b[k]};
    p1.fs-=i;
    p2.fs-=i;
    p1.sc-=b[i];
    p2.sc-=b[i];
    return cross(p1,p2);
}


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 && tc(v[v.sz()-2],v[v.sz()-1],i)<0){
            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]*(v[i]-v[i-1])) > (((v[i]-v[i-1]) * b[v[i-1]] + j * (b[v[i]]-b[v[i-1]]))  )){
                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: 3580kb

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

input:

3
1 4 2
3 7 4

output:

NO

result:

ok answer is NO

Test #3:

score: 0
Accepted
time: 30ms
memory: 7380kb

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:

NO

result:

ok answer is NO

Test #4:

score: -100
Wrong Answer
time: 25ms
memory: 5460kb

input:

221577
208524335 361831745 22019877 116938872 278766714 208490439 171991803 306449871 80504409 482889061 476216429 301986974 27811645 339159639 66711961 161280073 484108185 49066593 138136569 482494706 410430125 227818963 2765261 373817725 460818032 441004900 291595145 154693942 282220531 451435733 ...

output:

NO

result:

wrong answer expected YES, found NO