# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
568786 |
2022-05-26T08:05:29 Z |
errorgorn |
Fish 2 (JOI22_fish2) |
C++17 |
|
4000 ms |
6604 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,q;
int arr[100005];
vector<int> al[100005];
ii dfs(int i){
int tot=arr[i];
int num=1;
for (auto it:al[i]){
auto temp=dfs(it);
if (temp.fi>=arr[i]) num+=temp.se;
tot+=temp.fi;
}
return {tot,num};
}
int solve(int i,int j){
rep(x,i,j+1) al[x].clear();
vector<int> stk;
rep(x,i,j+1){
while (!stk.empty() && arr[stk.back()]<=arr[x]){
int temp=stk.back(); stk.pob();
if (stk.empty() || arr[stk.back()]>arr[x]) al[x].pub(temp);
else al[stk.back()].pub(temp);
}
stk.pub(x);
}
while (sz(stk)>=2){
int temp=stk.back(); stk.pob();
al[stk.back()].pub(temp);
}
return dfs(stk.back()).se;
}
signed main(){
cin.tie(0);
cout.tie(0);
cin.sync_with_stdio(false);
cin>>n;
rep(x,1,n+1) cin>>arr[x];
cin>>q;
int a,b;
rep(x,0,q){
cin>>a;
if (a==1){
cin>>a>>b;
arr[a]=b;
}
else{
cin>>a>>b;
cout<<solve(a,b)<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
3 ms |
2644 KB |
Output is correct |
10 |
Correct |
3 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
4 ms |
2700 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2644 KB |
Output is correct |
16 |
Correct |
3 ms |
2644 KB |
Output is correct |
17 |
Correct |
3 ms |
2644 KB |
Output is correct |
18 |
Correct |
3 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2644 KB |
Output is correct |
20 |
Correct |
5 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
17 ms |
6472 KB |
Output is correct |
3 |
Correct |
17 ms |
6188 KB |
Output is correct |
4 |
Correct |
17 ms |
6468 KB |
Output is correct |
5 |
Correct |
16 ms |
6160 KB |
Output is correct |
6 |
Correct |
20 ms |
5448 KB |
Output is correct |
7 |
Correct |
17 ms |
5588 KB |
Output is correct |
8 |
Correct |
21 ms |
5500 KB |
Output is correct |
9 |
Correct |
16 ms |
5588 KB |
Output is correct |
10 |
Correct |
19 ms |
6480 KB |
Output is correct |
11 |
Correct |
17 ms |
6108 KB |
Output is correct |
12 |
Correct |
15 ms |
5504 KB |
Output is correct |
13 |
Correct |
14 ms |
5580 KB |
Output is correct |
14 |
Correct |
15 ms |
5252 KB |
Output is correct |
15 |
Correct |
17 ms |
5784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
3 ms |
2644 KB |
Output is correct |
10 |
Correct |
3 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
4 ms |
2700 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2644 KB |
Output is correct |
16 |
Correct |
3 ms |
2644 KB |
Output is correct |
17 |
Correct |
3 ms |
2644 KB |
Output is correct |
18 |
Correct |
3 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2644 KB |
Output is correct |
20 |
Correct |
5 ms |
2644 KB |
Output is correct |
21 |
Correct |
2 ms |
2644 KB |
Output is correct |
22 |
Correct |
17 ms |
6472 KB |
Output is correct |
23 |
Correct |
17 ms |
6188 KB |
Output is correct |
24 |
Correct |
17 ms |
6468 KB |
Output is correct |
25 |
Correct |
16 ms |
6160 KB |
Output is correct |
26 |
Correct |
20 ms |
5448 KB |
Output is correct |
27 |
Correct |
17 ms |
5588 KB |
Output is correct |
28 |
Correct |
21 ms |
5500 KB |
Output is correct |
29 |
Correct |
16 ms |
5588 KB |
Output is correct |
30 |
Correct |
19 ms |
6480 KB |
Output is correct |
31 |
Correct |
17 ms |
6108 KB |
Output is correct |
32 |
Correct |
15 ms |
5504 KB |
Output is correct |
33 |
Correct |
14 ms |
5580 KB |
Output is correct |
34 |
Correct |
15 ms |
5252 KB |
Output is correct |
35 |
Correct |
17 ms |
5784 KB |
Output is correct |
36 |
Correct |
302 ms |
6504 KB |
Output is correct |
37 |
Correct |
530 ms |
6084 KB |
Output is correct |
38 |
Correct |
574 ms |
6320 KB |
Output is correct |
39 |
Correct |
156 ms |
6512 KB |
Output is correct |
40 |
Correct |
598 ms |
6172 KB |
Output is correct |
41 |
Correct |
739 ms |
5532 KB |
Output is correct |
42 |
Correct |
918 ms |
5536 KB |
Output is correct |
43 |
Correct |
711 ms |
5740 KB |
Output is correct |
44 |
Correct |
863 ms |
5784 KB |
Output is correct |
45 |
Correct |
362 ms |
6604 KB |
Output is correct |
46 |
Correct |
471 ms |
6492 KB |
Output is correct |
47 |
Correct |
732 ms |
6288 KB |
Output is correct |
48 |
Correct |
340 ms |
5612 KB |
Output is correct |
49 |
Correct |
998 ms |
5580 KB |
Output is correct |
50 |
Correct |
408 ms |
5304 KB |
Output is correct |
51 |
Correct |
1922 ms |
5880 KB |
Output is correct |
52 |
Correct |
2105 ms |
5236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
17 ms |
6472 KB |
Output is correct |
3 |
Correct |
17 ms |
6188 KB |
Output is correct |
4 |
Correct |
17 ms |
6468 KB |
Output is correct |
5 |
Correct |
16 ms |
6160 KB |
Output is correct |
6 |
Correct |
20 ms |
5448 KB |
Output is correct |
7 |
Correct |
17 ms |
5588 KB |
Output is correct |
8 |
Correct |
21 ms |
5500 KB |
Output is correct |
9 |
Correct |
16 ms |
5588 KB |
Output is correct |
10 |
Correct |
19 ms |
6480 KB |
Output is correct |
11 |
Correct |
17 ms |
6108 KB |
Output is correct |
12 |
Correct |
15 ms |
5504 KB |
Output is correct |
13 |
Correct |
14 ms |
5580 KB |
Output is correct |
14 |
Correct |
15 ms |
5252 KB |
Output is correct |
15 |
Correct |
17 ms |
5784 KB |
Output is correct |
16 |
Correct |
3 ms |
2644 KB |
Output is correct |
17 |
Execution timed out |
4051 ms |
6284 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
17 ms |
6472 KB |
Output is correct |
3 |
Correct |
17 ms |
6188 KB |
Output is correct |
4 |
Correct |
17 ms |
6468 KB |
Output is correct |
5 |
Correct |
16 ms |
6160 KB |
Output is correct |
6 |
Correct |
20 ms |
5448 KB |
Output is correct |
7 |
Correct |
17 ms |
5588 KB |
Output is correct |
8 |
Correct |
21 ms |
5500 KB |
Output is correct |
9 |
Correct |
16 ms |
5588 KB |
Output is correct |
10 |
Correct |
19 ms |
6480 KB |
Output is correct |
11 |
Correct |
17 ms |
6108 KB |
Output is correct |
12 |
Correct |
15 ms |
5504 KB |
Output is correct |
13 |
Correct |
14 ms |
5580 KB |
Output is correct |
14 |
Correct |
15 ms |
5252 KB |
Output is correct |
15 |
Correct |
17 ms |
5784 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Execution timed out |
4078 ms |
6476 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
3 ms |
2644 KB |
Output is correct |
10 |
Correct |
3 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
4 ms |
2700 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2644 KB |
Output is correct |
16 |
Correct |
3 ms |
2644 KB |
Output is correct |
17 |
Correct |
3 ms |
2644 KB |
Output is correct |
18 |
Correct |
3 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2644 KB |
Output is correct |
20 |
Correct |
5 ms |
2644 KB |
Output is correct |
21 |
Correct |
2 ms |
2644 KB |
Output is correct |
22 |
Correct |
17 ms |
6472 KB |
Output is correct |
23 |
Correct |
17 ms |
6188 KB |
Output is correct |
24 |
Correct |
17 ms |
6468 KB |
Output is correct |
25 |
Correct |
16 ms |
6160 KB |
Output is correct |
26 |
Correct |
20 ms |
5448 KB |
Output is correct |
27 |
Correct |
17 ms |
5588 KB |
Output is correct |
28 |
Correct |
21 ms |
5500 KB |
Output is correct |
29 |
Correct |
16 ms |
5588 KB |
Output is correct |
30 |
Correct |
19 ms |
6480 KB |
Output is correct |
31 |
Correct |
17 ms |
6108 KB |
Output is correct |
32 |
Correct |
15 ms |
5504 KB |
Output is correct |
33 |
Correct |
14 ms |
5580 KB |
Output is correct |
34 |
Correct |
15 ms |
5252 KB |
Output is correct |
35 |
Correct |
17 ms |
5784 KB |
Output is correct |
36 |
Correct |
302 ms |
6504 KB |
Output is correct |
37 |
Correct |
530 ms |
6084 KB |
Output is correct |
38 |
Correct |
574 ms |
6320 KB |
Output is correct |
39 |
Correct |
156 ms |
6512 KB |
Output is correct |
40 |
Correct |
598 ms |
6172 KB |
Output is correct |
41 |
Correct |
739 ms |
5532 KB |
Output is correct |
42 |
Correct |
918 ms |
5536 KB |
Output is correct |
43 |
Correct |
711 ms |
5740 KB |
Output is correct |
44 |
Correct |
863 ms |
5784 KB |
Output is correct |
45 |
Correct |
362 ms |
6604 KB |
Output is correct |
46 |
Correct |
471 ms |
6492 KB |
Output is correct |
47 |
Correct |
732 ms |
6288 KB |
Output is correct |
48 |
Correct |
340 ms |
5612 KB |
Output is correct |
49 |
Correct |
998 ms |
5580 KB |
Output is correct |
50 |
Correct |
408 ms |
5304 KB |
Output is correct |
51 |
Correct |
1922 ms |
5880 KB |
Output is correct |
52 |
Correct |
2105 ms |
5236 KB |
Output is correct |
53 |
Correct |
3 ms |
2644 KB |
Output is correct |
54 |
Execution timed out |
4051 ms |
6284 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |