QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404248 | #6326. Make Convex Sequence | comeintocalm# | WA | 133ms | 6184kb | C++20 | 1.4kb | 2024-05-03 16:50:03 | 2024-05-03 16:50:04 |
Judging History
answer
#include <bits/stdc++.h>
int main() {
int n;
std::cin >> n;
std::vector<int> l(n), r(n), a(n);
for (auto &x: l) {
std::cin >> x;
}
std::vector<std::pair<int,int>> c;
int t = 0;
for (int i = 0; i < n; ++i) {
std::cin >> r[i];
int x = r[i];
if (t >= 2 && (l[i] - c[t - 1].second) / (i - c[t - 1].first) <
(c[t - 1].second - c[t - 2].second) / (c[t - 1].first - c[t - 2].first)) {
--t;
}
if (t >= c.size()) {
c.emplace_back(i, x);
++t;
} else {
c[t++] = {i, x};
}
}
//for (int i = 0; i < t; ++i) {
// std::cout << c[i].first << ' ' << c[i].second << '\n';
//}
int h = -1;
for (int i = 0; i < n; ++i) {
if (h + 1 < t && c[h + 1].first == i) {
++h;
continue;
}
/// std::cout << h << ":\n";
/// std::cout << c[h].first << ' ' << c[h].second << '\n';
/// std::cout << c[h + 1].first << ' ' << c[h + 1].second << '\n';
/// std::cout << i << ' ' << l[i] << '\n';
if ((c[h + 1].second - l[i]) * (i - c[h].first) <
(l[i] - c[h].second) * (c[h + 1].first - i)) {
std::cout << "No\n";
return 0;
}
}
std::cout << "Yes\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3752kb
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: 3736kb
input:
3 1 4 2 3 7 4
output:
No
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 133ms
memory: 6184kb
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: 113ms
memory: 5744kb
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