QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100638 | #6326. Make Convex Sequence | SolitaryDream# | WA | 52ms | 5512kb | C++20 | 816b | 2023-04-27 14:43:09 | 2023-04-27 14:43:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, L[N], R[N];
bool chk(int x,int y,int z)
{
return 1ll*(R[z]-R[y])*(y-x)<(R[y]-R[x])*(z-y);
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", L + i);
for (int i = 1; i <= n; ++i) scanf("%d", R + i);
vector<int>st;
for(int i=1;i<=n;i++)
{
while(st.size()>1&&chk(st[st.size()-2],st[st.size()-1],i))
st.pop_back();
st.push_back(i);
}
bool ok=1;
for(int i=0;i+1<st.size();i++)
for(int j=st[i];j<=st[i+1];j++)
{
int l=st[i],r=st[i+1];
ok&=(1ll*(L[j]-R[l])*(r-l)<=1ll*(j-l)*(R[r]-R[l])&&1ll*(j-l)*(R[r]-R[l])<=1ll*(R[j]-R[l])*(r-l));
}
puts(ok?"Yes":"No");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3488kb
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: 3464kb
input:
3 1 4 2 3 7 4
output:
No
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 52ms
memory: 5512kb
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: 31ms
memory: 5224kb
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