QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105850#6326. Make Convex SequenceSommohito#WA 44ms7908kbC++201.4kb2023-05-15 17:54:182023-05-15 17:54:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-15 17:54:20]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:7908kb
  • [2023-05-15 17:54:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()

const int N = 3e5 +5;
typedef pair<int,int> pii;
typedef long double ld;

int n;
ll L[N],R[N];
const ld eps=1e-6;

void TEST_CASES()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>L[i];
    for(int i=0;i<n;i++) cin>>R[i];

    ld x=0,y=R[0];
    ld low=-1e50,high=1e50;
    int i=1;
    ld last_x,last_y;
    while(i<n)
    {
        ld temp_low=(L[i]-y)*1.0/(i-x);
        ld temp_high=(R[i]-y)*1.0/(i-x);

        if(temp_high+eps<low)
        {
            cout<<"NO\n";
            return;
        }

        if(high+eps<temp_low)
        {
            x=last_x;
            y=last_y;

            low=high;
            high=1e50;

            continue;
        }

        low=max(low,temp_low)-eps;
        high=min(high,temp_high)+eps;


        last_x=i;
        last_y=y+(i-x)*high;
        i++;
    }
    cout<<"YES\n";

}




/*
4
1 2 4 9
1 2 4 9
*/



int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        TEST_CASES();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 5512kb

input:

4
2 1 2 5
4 6 5 8

output:

YES

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 2ms
memory: 5424kb

input:

3
1 4 2
3 7 4

output:

NO

result:

ok answer is NO

Test #3:

score: 0
Accepted
time: 44ms
memory: 7908kb

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: 34ms
memory: 7348kb

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