Submission #1081427

# Submission time Handle Problem Language Result Execution time Memory
1081427 2024-08-30T04:42:49 Z isaachew Fish 2 (JOI22_fish2) C++17
25 / 100
4000 ms 2108 KB
#include <bits/stdc++.h>

int main(){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    int n,q;
    std::cin>>n;
    std::vector<int> vec;
    for(int i=0;i<n;i++){
        int x;
        std::cin>>x;
        vec.push_back(x);
    }
    std::cin>>q;
    for(;q--;){
        int a;
        std::cin>>a;
        if(a==1){
            int b,c;
            std::cin>>b>>c;
            b--;
            vec[b]=c;
        }else{
            int b,c;
            std::cin>>b>>c;
            b--;
            std::vector<long long> sums;
            std::vector<std::pair<long long,std::pair<long long,int>>> stk;//size of fish to the right, sum, number which can win
            for(int i=b;i<c;i++){
                stk.push_back({0,{0,0}});//for merging
                while(stk.size()>=2&&stk[stk.size()-2].first<vec[i]){
                    //std::cout<<"m!\n";
                    if(stk.back().second.first>=stk[stk.size()-2].first){
                        stk[stk.size()-2].second.second+=stk.back().second.second;
                    }
                    stk[stk.size()-2].second.first+=stk.back().second.first;//add sum
                    stk.pop_back();
                }
                stk.back().first=vec[i];
                stk.back().second.second=stk.back().second.first>=vec[i]?stk.back().second.second+1:1;
                stk.back().second.first+=vec[i];
            }
            while(stk.size()>=2){
                //std::cout<<"m\m";
                if(stk.back().second.first>=stk[stk.size()-2].first){
                    stk[stk.size()-2].second.second+=stk.back().second.second;
                }
                stk[stk.size()-2].second.first+=stk.back().second.first;//add sum
                stk.pop_back();
            }
            std::cout<<stk.back().second.second<<'\n';
        }
        
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 7 ms 1504 KB Output is correct
3 Correct 6 ms 1248 KB Output is correct
4 Correct 7 ms 1468 KB Output is correct
5 Correct 6 ms 1244 KB Output is correct
6 Correct 8 ms 1760 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 9 ms 1760 KB Output is correct
9 Correct 5 ms 1280 KB Output is correct
10 Correct 10 ms 1504 KB Output is correct
11 Correct 6 ms 1248 KB Output is correct
12 Correct 6 ms 1248 KB Output is correct
13 Correct 6 ms 1248 KB Output is correct
14 Correct 7 ms 1756 KB Output is correct
15 Correct 7 ms 1756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 7 ms 1504 KB Output is correct
23 Correct 6 ms 1248 KB Output is correct
24 Correct 7 ms 1468 KB Output is correct
25 Correct 6 ms 1244 KB Output is correct
26 Correct 8 ms 1760 KB Output is correct
27 Correct 5 ms 1108 KB Output is correct
28 Correct 9 ms 1760 KB Output is correct
29 Correct 5 ms 1280 KB Output is correct
30 Correct 10 ms 1504 KB Output is correct
31 Correct 6 ms 1248 KB Output is correct
32 Correct 6 ms 1248 KB Output is correct
33 Correct 6 ms 1248 KB Output is correct
34 Correct 7 ms 1756 KB Output is correct
35 Correct 7 ms 1756 KB Output is correct
36 Correct 172 ms 1584 KB Output is correct
37 Correct 278 ms 1248 KB Output is correct
38 Correct 298 ms 1244 KB Output is correct
39 Correct 71 ms 1504 KB Output is correct
40 Correct 330 ms 1244 KB Output is correct
41 Correct 281 ms 1756 KB Output is correct
42 Correct 367 ms 1944 KB Output is correct
43 Correct 301 ms 1248 KB Output is correct
44 Correct 350 ms 1248 KB Output is correct
45 Correct 185 ms 1504 KB Output is correct
46 Correct 255 ms 1504 KB Output is correct
47 Correct 376 ms 1248 KB Output is correct
48 Correct 112 ms 1248 KB Output is correct
49 Correct 368 ms 1244 KB Output is correct
50 Correct 217 ms 1756 KB Output is correct
51 Correct 793 ms 1756 KB Output is correct
52 Correct 955 ms 1764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 7 ms 1504 KB Output is correct
3 Correct 6 ms 1248 KB Output is correct
4 Correct 7 ms 1468 KB Output is correct
5 Correct 6 ms 1244 KB Output is correct
6 Correct 8 ms 1760 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 9 ms 1760 KB Output is correct
9 Correct 5 ms 1280 KB Output is correct
10 Correct 10 ms 1504 KB Output is correct
11 Correct 6 ms 1248 KB Output is correct
12 Correct 6 ms 1248 KB Output is correct
13 Correct 6 ms 1248 KB Output is correct
14 Correct 7 ms 1756 KB Output is correct
15 Correct 7 ms 1756 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 4091 ms 1616 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 7 ms 1504 KB Output is correct
3 Correct 6 ms 1248 KB Output is correct
4 Correct 7 ms 1468 KB Output is correct
5 Correct 6 ms 1244 KB Output is correct
6 Correct 8 ms 1760 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 9 ms 1760 KB Output is correct
9 Correct 5 ms 1280 KB Output is correct
10 Correct 10 ms 1504 KB Output is correct
11 Correct 6 ms 1248 KB Output is correct
12 Correct 6 ms 1248 KB Output is correct
13 Correct 6 ms 1248 KB Output is correct
14 Correct 7 ms 1756 KB Output is correct
15 Correct 7 ms 1756 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 4088 ms 2108 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 7 ms 1504 KB Output is correct
23 Correct 6 ms 1248 KB Output is correct
24 Correct 7 ms 1468 KB Output is correct
25 Correct 6 ms 1244 KB Output is correct
26 Correct 8 ms 1760 KB Output is correct
27 Correct 5 ms 1108 KB Output is correct
28 Correct 9 ms 1760 KB Output is correct
29 Correct 5 ms 1280 KB Output is correct
30 Correct 10 ms 1504 KB Output is correct
31 Correct 6 ms 1248 KB Output is correct
32 Correct 6 ms 1248 KB Output is correct
33 Correct 6 ms 1248 KB Output is correct
34 Correct 7 ms 1756 KB Output is correct
35 Correct 7 ms 1756 KB Output is correct
36 Correct 172 ms 1584 KB Output is correct
37 Correct 278 ms 1248 KB Output is correct
38 Correct 298 ms 1244 KB Output is correct
39 Correct 71 ms 1504 KB Output is correct
40 Correct 330 ms 1244 KB Output is correct
41 Correct 281 ms 1756 KB Output is correct
42 Correct 367 ms 1944 KB Output is correct
43 Correct 301 ms 1248 KB Output is correct
44 Correct 350 ms 1248 KB Output is correct
45 Correct 185 ms 1504 KB Output is correct
46 Correct 255 ms 1504 KB Output is correct
47 Correct 376 ms 1248 KB Output is correct
48 Correct 112 ms 1248 KB Output is correct
49 Correct 368 ms 1244 KB Output is correct
50 Correct 217 ms 1756 KB Output is correct
51 Correct 793 ms 1756 KB Output is correct
52 Correct 955 ms 1764 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Execution timed out 4091 ms 1616 KB Time limit exceeded
55 Halted 0 ms 0 KB -