QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404254 | #6326. Make Convex Sequence | comeintocalm# | WA | 131ms | 6192kb | C++20 | 1.4kb | 2024-05-03 16:57:51 | 2024-05-03 16:57:52 |
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];
while (t >= 2 && 1ll * (l[i] - c[t - 1].second) * (c[t - 1].first - c[t - 2].first) <
1ll * (c[t - 1].second - c[t - 2].second) * (i - c[t - 1].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 (1ll * (c[h + 1].second - l[i]) * (i - c[h].first) <
1ll * (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: 0ms
memory: 3476kb
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: 3564kb
input:
3 1 4 2 3 7 4
output:
No
result:
ok answer is NO
Test #3:
score: -100
Wrong Answer
time: 131ms
memory: 6192kb
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:
Yes
result:
wrong answer expected NO, found YES