# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951548 | pcc | Fish 2 (JOI22_fish2) | C++17 | 26 ms | 1372 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
const int mxn = 1e5+10;
int N,Q;
int arr[mxn];
namespace S1{
int calc(vector<int> &v){
int ans = 0;
for(int i = 0;i<v.size();i++){
int l = i,r = i;
ll sum = v[i];
while((l>0&&sum>=v[l-1])||(r+1<v.size()&&sum>=v[r+1])){
if(l>0&&sum>=v[l-1]){
l--;
sum += v[l];
}
else{
r++;
sum += v[r];
}
}
if(l == 0&&r+1 == v.size())ans++;
}
return ans;
}
void solve(){
cin>>Q;
while(Q--){
int l,r,t;
cin>>t>>l>>r;
if(t == 1){
arr[l] = r;
continue;
}
vector<int> v;
for(int i = l;i<=r;i++)v.push_back(arr[i]);
cout<<calc(v)<<'\n';
}
return;
}
}
namespace S2{
void solve(){
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N;
for(int i = 1;i<=N;i++)cin>>arr[i];
if(N<=500&&Q<=500)S1::solve();
else S2::solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |