QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105845 | #6326. Make Convex Sequence | Sommohito# | WA | 60ms | 7780kb | C++20 | 1.4kb | 2023-05-15 17:47:23 | 2023-05-15 17:47:25 |
Judging History
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);
high=min(high,temp_high);
if(high<low)
swap(high,low);
last_x=i;
last_y=y+(i-x)*high;
i++;
}
cout<<"YES\n";
}
/*
*/
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5352kb
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: 5460kb
input:
3 1 4 2 3 7 4
output:
NO
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 60ms
memory: 7780kb
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: 33ms
memory: 7468kb
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