QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404256#6326. Make Convex Sequencecomeintocalm#WA 134ms6324kbC++201.4kb2024-05-03 16:58:592024-05-03 16:59:01

Judging History

你现在查看的是最新测评结果

  • [2024-05-03 16:59:01]
  • 评测
  • 测评结果:WA
  • 用时:134ms
  • 内存:6324kb
  • [2024-05-03 16:58:59]
  • 提交

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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3732kb

input:

4
2 1 2 5
4 6 5 8

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

3
1 4 2
3 7 4

output:

No

result:

ok answer is NO

Test #3:

score: -100
Wrong Answer
time: 134ms
memory: 6324kb

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