QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#604686#6337. Mizuyokan 2Dimash#0 200ms9264kbC++231.9kb2024-10-02 13:10:272024-10-02 13:10:27

Judging History

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

  • [2024-10-02 13:10:27]
  • 评测
  • 测评结果:0
  • 用时:200ms
  • 内存:9264kb
  • [2024-10-02 13:10:27]
  • 提交

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;
const int  N = 1e6 + 12, MOD = (int)1e9 + 7;

int n, a[N], q;
ll sf[N];

int solve(int l, int r) {
    ll cur = 0;
    sf[r] = a[r];
    for(int i = r - 1; i >= l; i--) {
        sf[i] = sf[i + 1] + a[i];
    }
    int res = 1;
    for(int i = l; i <= r; i++) {
        cur += a[i];
        // cout << a[i] << ' ';
        auto get = [&](bool ok) {
            ll x = cur, t = 0;
            int ret = 0, bf = 0;
            for(int j = i + 1; j <= r; j++) {
                t += a[j];
                if(ok) {
                    if(t > x) {
                        x = t;
                        ret++;
                        bf = max(bf, 1 +ret);
                        ok ^= 1;
                        t = 0;
                    }
                } else {
                    if(t < x) {
                        x = t;
                        ret++;
                        t = 0;
                        ok ^= 1;
                    } else 
                        return bf;
                }
                if(t == 0 && !ok && sf[j + 1] < x) {
                    bf = max(bf, 1 + ret + 1);
                }
            }
            return ret + 1;
        };
        // if(i == 2) {
        //     cout << get(0) << '\n';
        // }
        res = max({res, get(0), get(1)});
    }
    return res;
}
void test() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    
    cin >> q;

    for(int i = 1; i <= q; i++) {
        int x, y, l, r;
        cin >> x >> y >> l >> r;
        l++;
        a[x] = y;
        // if(i == 1) continue;
        cout << solve(l, r) << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 

    int t = 1; 
    // cin >> t;
    
    while(t--) 
        test();
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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:

31
29
31
35
27
17
22
25

result:

wrong answer 1st numbers differ - expected: '59', found: '31'

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: 200ms
memory: 7156kb

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:

31
17
38
27
21
17
37
20
27
43
33
15
17
17
15
38
15
15
16
19
16
21
33
21
32
37
23
22
21
27
32
32
15
22
17
15
21
13
16
27
19
17
29
16
20
15
33
17
35
21
29
16
21
27
16
31
31
23
33
15
21
31
37
43
9
15
14
25
10
29
13
15
23
21
32
31
15
27
21
16
35
32
23
9
40
14
39
19
33
29
24
26
14
33
15
13
35
33
41
43
27...

result:

wrong answer 1st numbers differ - expected: '59', found: '31'

Subtask #5:

score: 0
Wrong Answer

Test #76:

score: 0
Wrong Answer
time: 198ms
memory: 9264kb

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:

19
32
38
33
21
13
37
28
23
18
9
27
16
24
13
32
33
33
40
11
16
27
33
33
13
26
28
30
21
33
40
36
21
28
9
15
35
40
31
15
29
17
18
33
16
24
11
29
29
34
15
26
9
15
28
38
32
37
33
9
15
29
15
22
27
9
14
34
29
14
15
21
32
40
38
23
29
15
15
29
20
24
23
23
14
26
21
33
15
23
16
38
21
33
13
16
35
25
16
21
15
27...

result:

wrong answer 1st numbers differ - expected: '34', found: '19'

Subtask #6:

score: 0
Skipped

Dependency #1:

0%