# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
781590 |
2023-07-13T08:22:15 Z |
Dan4Life |
Fish 2 (JOI22_fish2) |
C++17 |
|
13 ms |
2864 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, q, a[100010], pr[100010];
using ar = array<int,2>;
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
cin >> q; a[n+1] = (int)1e18;
while(q--){
int t, l, r; cin >> t >> l >> r;
if(t==1) a[l]=r;
else{
stack<ar> S; int sum = 0, ind;
for(int i = l; i <= r; i++)pr[i]=0;
for(int i = l; i <= r; i++){
sum = 0, ind = -1;
while(!S.empty() and a[S.top()[1]] < a[i])
sum+=S.top()[0]+a[S.top()[1]], S.pop();
if(sum<a[i]) ind=S.empty()?l:(S.top()[1]+1);
if(ind!=-1 and ind<i) pr[ind]++, pr[i]--;
S.push({sum,i});
}
S = stack<ar>();
for(int i = r+1; i > l; i--){
sum = 0, ind = -1;
while(!S.empty() and a[S.top()[1]] < a[i])
sum+=S.top()[0]+a[S.top()[1]], S.pop();
if(sum<a[i]) ind=S.empty()?n:S.top()[1];
if(ind!=-1 and i+1<ind) pr[i+1]++, pr[ind]--;
S.push({sum,i});
}
int ans = 0, xd=0;
for(int i = l; i <= r; i++)
xd+=pr[i], ans+=!xd;
cout << ans << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
9 ms |
1888 KB |
Output is correct |
3 |
Correct |
9 ms |
2128 KB |
Output is correct |
4 |
Correct |
10 ms |
2420 KB |
Output is correct |
5 |
Correct |
8 ms |
2192 KB |
Output is correct |
6 |
Correct |
12 ms |
2736 KB |
Output is correct |
7 |
Correct |
9 ms |
2004 KB |
Output is correct |
8 |
Incorrect |
13 ms |
2864 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
9 ms |
1888 KB |
Output is correct |
3 |
Correct |
9 ms |
2128 KB |
Output is correct |
4 |
Correct |
10 ms |
2420 KB |
Output is correct |
5 |
Correct |
8 ms |
2192 KB |
Output is correct |
6 |
Correct |
12 ms |
2736 KB |
Output is correct |
7 |
Correct |
9 ms |
2004 KB |
Output is correct |
8 |
Incorrect |
13 ms |
2864 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
9 ms |
1888 KB |
Output is correct |
3 |
Correct |
9 ms |
2128 KB |
Output is correct |
4 |
Correct |
10 ms |
2420 KB |
Output is correct |
5 |
Correct |
8 ms |
2192 KB |
Output is correct |
6 |
Correct |
12 ms |
2736 KB |
Output is correct |
7 |
Correct |
9 ms |
2004 KB |
Output is correct |
8 |
Incorrect |
13 ms |
2864 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |