QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#252883#6326. Make Convex Sequencestd_abs#WA 30ms7888kbC++141.2kb2023-11-16 14:17:472023-11-16 14:17:48

Judging History

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

  • [2023-11-16 14:17:48]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:7888kb
  • [2023-11-16 14:17:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
const int mod = 998244353, N = 300005;
typedef pair<int, int> pi;

ll operator ^ (pi x, pi y) {
    return 1ll * x.first * y.second - 1ll * x.second * y.first;
}

int l[N], r[N];
pi a[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> l[i];
    for (int i = 0; i < n; ++i)
        cin >> r[i];
    for (int i = 1; i < n; ++i)
        a[i - 1] = pi(1, r[i] - r[i - 1]);
    vector<pi> v;
    for (int i = 0; i < n - 1; ++i) {
        while (!v.empty() && (v.back() ^ a[i]) < 0) {
            a[i].first += v.back().first;
            a[i].second += v.back().second;
            v.pop_back();
        }
        v.push_back(a[i]);
    }
    int x1 = 0, y1 = r[0];
    for (auto [x, y] : v) {
        int x2 = x1 + x, y2 = y1 + y;
        for (int i = x1 + 1; i <= x2; ++i) {
            if ((y2 - y1) < 1ll * (l[i] - y1) * (x2 - x1))
                return cout << "No\n", 0;
        }
        x1 = x2, y1 = y2;
    }
    cout << "Yes\n";
}

详细

Test #1:

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

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: 5492kb

input:

3
1 4 2
3 7 4

output:

No

result:

ok answer is NO

Test #3:

score: -100
Wrong Answer
time: 30ms
memory: 7888kb

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