Submission #568721

# Submission time Handle Problem Language Result Execution time Memory
568721 2022-05-26T06:17:45 Z maomao90 Fish 2 (JOI22_fish2) C++17
13 / 100
4000 ms 1740 KB
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 200005;

int n;
int a[MAXN];
int q;

int ans;
void solve(int l, int r, int big = 0) {
    ll sm = 0;
    ii mx = {-1, -1};
    REP (i, l, r + 1) {
        sm += a[i];
        mxto(mx, ii{a[i], i});
    }
    if (sm < big) {
        return;
    }
    ans++;
    solve(l, mx.SE - 1, mx.FI);
    solve(mx.SE + 1, r, mx.FI);
}

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> n;
    REP (i, 1, n + 1) {
        cin >> a[i];
    }
    cin >> q;
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x, y; cin >> x >> y;
            a[x] = y;
        } else {
            int l, r; cin >> l >> r;
            ans = 0;
            solve(l, r);
            cout << ans << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 12 ms 1244 KB Output is correct
3 Correct 8 ms 980 KB Output is correct
4 Correct 13 ms 1280 KB Output is correct
5 Correct 9 ms 988 KB Output is correct
6 Correct 15 ms 1536 KB Output is correct
7 Correct 6 ms 856 KB Output is correct
8 Correct 17 ms 1728 KB Output is correct
9 Correct 6 ms 852 KB Output is correct
10 Correct 18 ms 1288 KB Output is correct
11 Correct 9 ms 972 KB Output is correct
12 Correct 10 ms 852 KB Output is correct
13 Correct 10 ms 856 KB Output is correct
14 Correct 380 ms 1412 KB Output is correct
15 Correct 460 ms 1520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 12 ms 1244 KB Output is correct
23 Correct 8 ms 980 KB Output is correct
24 Correct 13 ms 1280 KB Output is correct
25 Correct 9 ms 988 KB Output is correct
26 Correct 15 ms 1536 KB Output is correct
27 Correct 6 ms 856 KB Output is correct
28 Correct 17 ms 1728 KB Output is correct
29 Correct 6 ms 852 KB Output is correct
30 Correct 18 ms 1288 KB Output is correct
31 Correct 9 ms 972 KB Output is correct
32 Correct 10 ms 852 KB Output is correct
33 Correct 10 ms 856 KB Output is correct
34 Correct 380 ms 1412 KB Output is correct
35 Correct 460 ms 1520 KB Output is correct
36 Correct 2009 ms 1404 KB Output is correct
37 Correct 345 ms 980 KB Output is correct
38 Correct 350 ms 1052 KB Output is correct
39 Correct 454 ms 1356 KB Output is correct
40 Correct 465 ms 1176 KB Output is correct
41 Correct 871 ms 1696 KB Output is correct
42 Correct 1156 ms 1740 KB Output is correct
43 Correct 199 ms 912 KB Output is correct
44 Correct 156 ms 896 KB Output is correct
45 Correct 978 ms 1304 KB Output is correct
46 Correct 790 ms 1288 KB Output is correct
47 Correct 401 ms 1000 KB Output is correct
48 Correct 92 ms 984 KB Output is correct
49 Correct 299 ms 1004 KB Output is correct
50 Execution timed out 4089 ms 1576 KB Time limit exceeded
51 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 12 ms 1244 KB Output is correct
3 Correct 8 ms 980 KB Output is correct
4 Correct 13 ms 1280 KB Output is correct
5 Correct 9 ms 988 KB Output is correct
6 Correct 15 ms 1536 KB Output is correct
7 Correct 6 ms 856 KB Output is correct
8 Correct 17 ms 1728 KB Output is correct
9 Correct 6 ms 852 KB Output is correct
10 Correct 18 ms 1288 KB Output is correct
11 Correct 9 ms 972 KB Output is correct
12 Correct 10 ms 852 KB Output is correct
13 Correct 10 ms 856 KB Output is correct
14 Correct 380 ms 1412 KB Output is correct
15 Correct 460 ms 1520 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Execution timed out 4075 ms 1332 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 12 ms 1244 KB Output is correct
3 Correct 8 ms 980 KB Output is correct
4 Correct 13 ms 1280 KB Output is correct
5 Correct 9 ms 988 KB Output is correct
6 Correct 15 ms 1536 KB Output is correct
7 Correct 6 ms 856 KB Output is correct
8 Correct 17 ms 1728 KB Output is correct
9 Correct 6 ms 852 KB Output is correct
10 Correct 18 ms 1288 KB Output is correct
11 Correct 9 ms 972 KB Output is correct
12 Correct 10 ms 852 KB Output is correct
13 Correct 10 ms 856 KB Output is correct
14 Correct 380 ms 1412 KB Output is correct
15 Correct 460 ms 1520 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Execution timed out 4081 ms 1584 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 12 ms 1244 KB Output is correct
23 Correct 8 ms 980 KB Output is correct
24 Correct 13 ms 1280 KB Output is correct
25 Correct 9 ms 988 KB Output is correct
26 Correct 15 ms 1536 KB Output is correct
27 Correct 6 ms 856 KB Output is correct
28 Correct 17 ms 1728 KB Output is correct
29 Correct 6 ms 852 KB Output is correct
30 Correct 18 ms 1288 KB Output is correct
31 Correct 9 ms 972 KB Output is correct
32 Correct 10 ms 852 KB Output is correct
33 Correct 10 ms 856 KB Output is correct
34 Correct 380 ms 1412 KB Output is correct
35 Correct 460 ms 1520 KB Output is correct
36 Correct 2009 ms 1404 KB Output is correct
37 Correct 345 ms 980 KB Output is correct
38 Correct 350 ms 1052 KB Output is correct
39 Correct 454 ms 1356 KB Output is correct
40 Correct 465 ms 1176 KB Output is correct
41 Correct 871 ms 1696 KB Output is correct
42 Correct 1156 ms 1740 KB Output is correct
43 Correct 199 ms 912 KB Output is correct
44 Correct 156 ms 896 KB Output is correct
45 Correct 978 ms 1304 KB Output is correct
46 Correct 790 ms 1288 KB Output is correct
47 Correct 401 ms 1000 KB Output is correct
48 Correct 92 ms 984 KB Output is correct
49 Correct 299 ms 1004 KB Output is correct
50 Execution timed out 4089 ms 1576 KB Time limit exceeded
51 Halted 0 ms 0 KB -