QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100845#1808. Efficient Partitioningckiseki#WA 2ms3428kbC++201.0kb2023-04-28 12:57:002023-04-28 12:57:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 12:57:04]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3428kb
  • [2023-04-28 12:57:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int N;
    cin >> N;

    vector<int> a(N + 1), b(N + 1), c(N + 1);
    vector<int64_t> pre(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= N; i++) {
        cin >> b[i];
    }
    for (int i = 1; i <= N; i++) {
        cin >> c[i];
    }

    for (int i = 1; i <= N; i++) {
        pre[i] = pre[i - 1] + a[i];
    }

    vector<int> dp(N + 1);

    const auto ok = [&](int64_t L) {
        fill(dp.begin(), dp.end(), false);
        int64_t mx = -pre[0] + b[1];
        for (int i = 1; i <= N; i++) {
            if (pre[i] + c[i] + mx >= L) {
                dp[i] = true;
                if (i < N)
                    mx = max(mx, -pre[i] + b[i + 1]);
            }
        }
        return dp[N];
    };

    int64_t ans = 0;
    for (int64_t s = 1LL << 60; s; s >>= 1) {
        if (ok(ans + s)) {
            ans += s;
        }
    }

    cout << ans << '\n';
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3364kb

input:

2
1 -1
-1 4
1 -2

output:

1

result:

ok answer is '1'

Test #2:

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

input:

1
1000000000
1000000000
1000000000

output:

3000000000

result:

ok answer is '3000000000'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3428kb

input:

11
-323225375 -897098227 -795978453 501188072 409939326 -362890219 969123048 962633819 252457646 694824070 -406990840
-696821643 -663750226 -570551722 670541392 172964990 399404695 -305728788 -157617655 -801518744 -328729631 -160335217
-465411342 -660775657 515997870 -34787742 628368976 84800619 -72...

output:

91174984

result:

ok answer is '91174984'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3408kb

input:

2
12 3
-13 -1
-19 7

output:

9

result:

ok answer is '9'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3412kb

input:

9
-13 -10 18 4 -9 8 -12 18 1
3 3 7 10 -16 -10 8 -7 -19
-20 15 -17 2 7 15 11 14 8

output:

16

result:

ok answer is '16'

Test #6:

score: -100
Wrong Answer
time: 2ms
memory: 3320kb

input:

10
-3 -20 -13 19 -12 2 -15 -9 -12 -15
8 20 8 19 9 -13 8 16 10 8
12 8 7 14 -1 -11 -7 -6 4 -7

output:

0

result:

wrong answer expected '-14', found '0'