Submission #951548

#TimeUsernameProblemLanguageResultExecution timeMemory
951548pccFish 2 (JOI22_fish2)C++17
5 / 100
26 ms1372 KiB
#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)

fish2.cpp: In function 'int S1::calc(std::vector<int>&)':
fish2.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(int i = 0;i<v.size();i++){
      |                 ~^~~~~~~~~
fish2.cpp:22:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    while((l>0&&sum>=v[l-1])||(r+1<v.size()&&sum>=v[r+1])){
      |                               ~~~^~~~~~~~~
fish2.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(l == 0&&r+1 == v.size())ans++;
      |               ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...