답안 #727751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727751 2023-04-21T09:22:47 Z fatemetmhr Fish 2 (JOI22_fish2) C++17
25 / 100
944 ms 2900 KB
// Be name khoda //

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second
#define mp     make_pair

const int maxn5 = 1e5 + 10;
const int maxnt = 4e6 + 10;
const ll  inf   = 1e18;

int cnt[maxn5], a[maxn5], av[maxn5], lq, rq;
ll ps[maxn5];

inline void check(int l, int r){
    if(r == l + 1)
        return;
    ll sum = ps[r - 1] - (l == -1 ? 0 : ps[l]);
    //cout << "checking " << l << ' ' << r << ' ' << sum << endl;
    if(sum >= min(r >= rq ? inf : a[r], l < lq ? inf : a[l]))
        return;
    //cout << "ya " << l << ' ' << r << endl;
    cnt[l + 1]++;
    cnt[r]--;
}


inline void solve1(int n, int q){

    ios_base::sync_with_stdio(false); cin.tie(0);

    ps[0] = a[0];
    for(int i = 1; i < n; i++)
        ps[i] = ps[i - 1] + a[i];

    while(q--){
        int ty, l, r; cin >> ty >> l >> r;
        l--;
        if(ty == 1){
            a[l] = r;
            ps[0] = a[0];
            for(int i = 1; i < n; i++)
                ps[i] = ps[i - 1] + a[i];
        }
        else{
            int pt = 0;
            lq = l; rq = r;
            memset(cnt, 0, sizeof cnt);
            for(int i = l; i < r; i++){
                while(pt && a[av[pt - 1]] < a[i]){
                    check(av[pt - 1], i);
                    pt--;
                }
                //cout << "ok " << i << ' ' << pt << ' ' << (pt ? av[pt - 1] : lq - 1) << ' ' << a[5] << ' ' << a[i] << endl;
                check(pt ? av[pt - 1] : lq - 1, i);
                av[pt++] = i;
            }
            for(int i = 0; i < pt; i++)
                check(av[i], rq);
            int cur = 0, ans = 0;
            for(int i = l; i < r; i++){
                cur += cnt[i];
                if(!cur)
                    ans++;
            }
            cout << ans << '\n';
        }
    }
}

inline void solve2(int n, int q){

}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n; cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int q; cin >> q;
    if(q <= 1000)
        solve1(n, q);
    else
        solve2(n, q);

}

/*
5
6 4 2 2 6
1
2 1 5
2 1 3
1 3 1
2 2 5
2 1 5
2 2 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 712 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 6 ms 724 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 6 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 5 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 6 ms 740 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 5 ms 724 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 6 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 16 ms 2352 KB Output is correct
3 Correct 9 ms 2204 KB Output is correct
4 Correct 11 ms 2356 KB Output is correct
5 Correct 9 ms 2260 KB Output is correct
6 Correct 13 ms 2764 KB Output is correct
7 Correct 9 ms 2104 KB Output is correct
8 Correct 11 ms 2768 KB Output is correct
9 Correct 7 ms 2004 KB Output is correct
10 Correct 13 ms 2436 KB Output is correct
11 Correct 8 ms 2136 KB Output is correct
12 Correct 8 ms 2032 KB Output is correct
13 Correct 7 ms 2132 KB Output is correct
14 Correct 11 ms 2472 KB Output is correct
15 Correct 10 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 712 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 6 ms 724 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 6 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 5 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 6 ms 740 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 5 ms 724 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 6 ms 748 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 16 ms 2352 KB Output is correct
23 Correct 9 ms 2204 KB Output is correct
24 Correct 11 ms 2356 KB Output is correct
25 Correct 9 ms 2260 KB Output is correct
26 Correct 13 ms 2764 KB Output is correct
27 Correct 9 ms 2104 KB Output is correct
28 Correct 11 ms 2768 KB Output is correct
29 Correct 7 ms 2004 KB Output is correct
30 Correct 13 ms 2436 KB Output is correct
31 Correct 8 ms 2136 KB Output is correct
32 Correct 8 ms 2032 KB Output is correct
33 Correct 7 ms 2132 KB Output is correct
34 Correct 11 ms 2472 KB Output is correct
35 Correct 10 ms 2408 KB Output is correct
36 Correct 162 ms 2488 KB Output is correct
37 Correct 217 ms 2224 KB Output is correct
38 Correct 229 ms 2220 KB Output is correct
39 Correct 109 ms 2472 KB Output is correct
40 Correct 265 ms 2220 KB Output is correct
41 Correct 367 ms 2888 KB Output is correct
42 Correct 461 ms 2900 KB Output is correct
43 Correct 386 ms 2092 KB Output is correct
44 Correct 450 ms 2096 KB Output is correct
45 Correct 153 ms 2388 KB Output is correct
46 Correct 193 ms 2640 KB Output is correct
47 Correct 247 ms 2172 KB Output is correct
48 Correct 191 ms 2136 KB Output is correct
49 Correct 456 ms 2140 KB Output is correct
50 Correct 220 ms 2460 KB Output is correct
51 Correct 944 ms 2516 KB Output is correct
52 Correct 871 ms 2628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 16 ms 2352 KB Output is correct
3 Correct 9 ms 2204 KB Output is correct
4 Correct 11 ms 2356 KB Output is correct
5 Correct 9 ms 2260 KB Output is correct
6 Correct 13 ms 2764 KB Output is correct
7 Correct 9 ms 2104 KB Output is correct
8 Correct 11 ms 2768 KB Output is correct
9 Correct 7 ms 2004 KB Output is correct
10 Correct 13 ms 2436 KB Output is correct
11 Correct 8 ms 2136 KB Output is correct
12 Correct 8 ms 2032 KB Output is correct
13 Correct 7 ms 2132 KB Output is correct
14 Correct 11 ms 2472 KB Output is correct
15 Correct 10 ms 2408 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Incorrect 7 ms 1108 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 16 ms 2352 KB Output is correct
3 Correct 9 ms 2204 KB Output is correct
4 Correct 11 ms 2356 KB Output is correct
5 Correct 9 ms 2260 KB Output is correct
6 Correct 13 ms 2764 KB Output is correct
7 Correct 9 ms 2104 KB Output is correct
8 Correct 11 ms 2768 KB Output is correct
9 Correct 7 ms 2004 KB Output is correct
10 Correct 13 ms 2436 KB Output is correct
11 Correct 8 ms 2136 KB Output is correct
12 Correct 8 ms 2032 KB Output is correct
13 Correct 7 ms 2132 KB Output is correct
14 Correct 11 ms 2472 KB Output is correct
15 Correct 10 ms 2408 KB Output is correct
16 Correct 1 ms 716 KB Output is correct
17 Incorrect 9 ms 1364 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 712 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 6 ms 724 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 6 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 5 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 6 ms 740 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 5 ms 724 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 6 ms 748 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 16 ms 2352 KB Output is correct
23 Correct 9 ms 2204 KB Output is correct
24 Correct 11 ms 2356 KB Output is correct
25 Correct 9 ms 2260 KB Output is correct
26 Correct 13 ms 2764 KB Output is correct
27 Correct 9 ms 2104 KB Output is correct
28 Correct 11 ms 2768 KB Output is correct
29 Correct 7 ms 2004 KB Output is correct
30 Correct 13 ms 2436 KB Output is correct
31 Correct 8 ms 2136 KB Output is correct
32 Correct 8 ms 2032 KB Output is correct
33 Correct 7 ms 2132 KB Output is correct
34 Correct 11 ms 2472 KB Output is correct
35 Correct 10 ms 2408 KB Output is correct
36 Correct 162 ms 2488 KB Output is correct
37 Correct 217 ms 2224 KB Output is correct
38 Correct 229 ms 2220 KB Output is correct
39 Correct 109 ms 2472 KB Output is correct
40 Correct 265 ms 2220 KB Output is correct
41 Correct 367 ms 2888 KB Output is correct
42 Correct 461 ms 2900 KB Output is correct
43 Correct 386 ms 2092 KB Output is correct
44 Correct 450 ms 2096 KB Output is correct
45 Correct 153 ms 2388 KB Output is correct
46 Correct 193 ms 2640 KB Output is correct
47 Correct 247 ms 2172 KB Output is correct
48 Correct 191 ms 2136 KB Output is correct
49 Correct 456 ms 2140 KB Output is correct
50 Correct 220 ms 2460 KB Output is correct
51 Correct 944 ms 2516 KB Output is correct
52 Correct 871 ms 2628 KB Output is correct
53 Correct 1 ms 724 KB Output is correct
54 Incorrect 7 ms 1108 KB Output isn't correct
55 Halted 0 ms 0 KB -