QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#132324 | #6326. Make Convex Sequence | UrgantTeam# | WA | 32ms | 5632kb | C++23 | 916b | 2023-07-29 15:54:08 | 2023-07-29 15:54:11 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long double ld;
typedef long long ll;
int down[300005], up[300005];
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> down[i];
for (int i = 1; i <= n; i++) cin >> up[i];
for (int i = 2; i <= n; i++) down[i] = max(down[i], down[i - 1]);
for (int i = n - 1; i >= 1; i--) up[i] = min(up[i], up[i + 1]);
for (int i = 1; i <= n; i++)
if (down[i] > up[i]) cout << "No\n", exit(0);
int last = up[1], step = 0;
for (int i = 2; i <= n; i++)
{
if (last + step > up[i]) cout << "No\n", exit(0);
if (last + step < down[i]) step = down[i] - last;
last += step;
}
cout << "Yes\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5632kb
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: 3640kb
input:
3 1 4 2 3 7 4
output:
No
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 32ms
memory: 5608kb
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: 21ms
memory: 5152kb
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