QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524747#6337. Mizuyokan 2Qwerty1232#0 95ms5104kbC++231.8kb2024-08-20 04:18:202024-08-20 04:18:21

Judging History

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

  • [2024-08-20 04:18:21]
  • 评测
  • 测评结果:0
  • 用时:95ms
  • 内存:5104kb
  • [2024-08-20 04:18:20]
  • 提交

answer

#include <bits/stdc++.h>

int32_t main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;
    std::vector<int> input(n);
    for (auto& i : input) {
        std::cin >> i;
    }
    int q;
    std::cin >> q;
    std::vector<std::array<int, 4>> quer(q);
    for (auto& [x, y, l, r] : quer) {
        std::cin >> x >> y >> l >> r;
        x--;
    }

    std::vector<int> ans(q);
    for (int i = 0; i < q; i++) {
        auto& [x, y, l, r] = quer[i];
        input[x] = y;
        std::vector<int> vec(input.begin() + l, input.begin() + r);
        int n = vec.size();
        std::vector<int> dp(n, -1e3);
        constexpr int K = 35;
        for (int i = 0; i + 1 < std::min(n, K); i++) {
            if (std::accumulate(vec.begin(), vec.begin() + i, 0ll) > vec[i]) {
                dp[i] = 2;
            }
        }
        for (int i = 0; i < n; i++) {
            int64_t sum = 0;
            int val = dp[i];
            for (int j = i - 1; j > std::max(0, i - K); j--) {
                sum += vec[j];
                if (vec[i] < sum && vec[j - 1] < sum) {
                    val = std::max(val, dp[j - 1] + 2);
                }
            }
            dp[i] = val;
        }
        int& res = ans[i];
        res = dp[n - 1];
        res = std::max(res, 1);
        if (n == 2 && vec[0] != vec[1] || n >= 3) {
            res = std::max(res, 2);
        }
        for (int i = std::max(0, n - K); i < n; i++) {
            if (std::accumulate(vec.begin() + i + 1, vec.begin() + n, 0ll) > vec[i]) {
                res = std::max(res, dp[i] + 1);
            }
        }
    }

    for (int i = 0; i < q; i++) {
        std::cout << ans[i] << "\n";
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

170
581553716 290776853 145388421 581553716 168947671 936760822 849346471 126291564 133104657 125887494 136786623 123143788 137803872 129733949 849346471 880499329 202732710 611312524 152828126 305656257 611312524 121295297 6875889 74507235 419967909 333601507 281557968 740824934 370412466 185206229...

output:

59
56
61
61
56
37
41
46

result:

wrong answer 7th numbers differ - expected: '42', found: '41'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #59:

score: 0
Wrong Answer
time: 95ms
memory: 5104kb

input:

185137
895278847 447639418 223819705 895278847 25847602 892542542 725274571 68345857 72124244 67050536 71135605 66549838 72378749 66083078 72261084 67667076 70423484 68942136 725274571 798132375 68764887 958288578 703862250 55104628 58120315 54690522 57110282 54279470 56516680 54581941 58474132 5445...

output:

59
25
79
55
43
41
79
36
57
79
69
29
31
25
26
75
32
25
26
35
33
38
67
40
66
71
45
39
49
52
63
60
29
39
39
34
41
19
28
51
31
43
61
22
30
26
73
39
63
36
53
26
46
56
29
67
60
37
71
22
42
59
67
87
16
27
19
38
13
63
20
19
41
34
54
53
15
51
43
28
71
59
49
9
75
17
86
29
73
61
37
45
20
62
20
20
67
71
83
82
5...

result:

wrong answer 2nd numbers differ - expected: '26', found: '25'

Subtask #5:

score: 0
Wrong Answer

Test #76:

score: 0
Wrong Answer
time: 94ms
memory: 4940kb

input:

235469
96936 48463 24226 96936 25951 73765 63933 7121 7884 7166 7731 7464 7559 7300 7767 7314 63933 88750 6093 115886 111307 16371 17529 15944 17376 16099 18186 15910 111307 116042 13997 111982 95565 10713 11748 10849 11375 11093 11406 10874 11810 11197 95565 98914 1302 65917 16473 32953 65917 15943...

output:

34
55
72
60
41
13
73
45
33
32
14
53
35
45
18
62
65
79
71
15
19
57
66
83
19
45
61
57
44
76
75
67
40
55
9
29
59
72
64
21
63
33
28
61
26
35
20
65
53
70
29
46
13
32
47
73
63
75
79
17
24
49
19
40
57
17
22
66
67
17
19
54
62
73
71
45
61
30
27
59
32
35
49
49
23
55
42
59
20
53
31
74
43
57
17
34
71
45
24
38
2...

result:

wrong answer 2nd numbers differ - expected: '56', found: '55'

Subtask #6:

score: 0
Skipped

Dependency #1:

0%