Submission #632039

#TimeUsernameProblemLanguageResultExecution timeMemory
632039Jovan26Addk (eJOI21_addk)C++14
0 / 100
132 ms2976 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin>>n; long long k; cin>>k; long long a[n]; for(long i=0;i<n;i++) cin>>a[i]; long long q; cin>>q; bool p = false; vector<long long> v; int pref[n]; pref[0] = a[0]; for(int i=1;i<n;i++){ pref[i] = pref[i-1]+a[i]; } for(long long j=0;j<q;j++){ int x; cin>>x; if(x==1){ int y; cin>>y; continue; } long long l,r,m; p = true; cin>>l>>r>>m; long long ma = min(m,(r-l+1-m+1)); long long rez = 0; for(long long i=l-1;i<l+ma-2;i++){ rez+=(i-l+2)*a[i]; } for(long long i=r-1;i>r-ma;i--){ rez+=(r-i)*a[i]; } int s = pref[r-ma]-pref[l+ma-3]; rez+=s*ma; v.push_back(rez); } if(p){ for(long long i=0;i<v.size()-1;i++) cout<<v[i]<<endl; cout<<v[v.size()-1]; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:45:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(long long i=0;i<v.size()-1;i++) cout<<v[i]<<endl;
      |                    ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...