Submission #633146

#TimeUsernameProblemLanguageResultExecution timeMemory
633146Jovan26Addk (eJOI21_addk)C++14
92 / 100
157 ms6616 KiB
#include<bits/stdc++.h> using namespace std; long long rez; int main(){ #define int long long ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin>>n; long long k; cin>>k; long long a[n]; long long pref[n+1]; for(long i=0;i<n;i++) cin>>a[i]; long long q; pref[0] = 0; int preff[n+1]; preff[0] = 0; for(int i=1;i<=n;i++){ pref[i] = pref[i-1]+a[i-1]; } for(int i=1;i<=n;i++){ preff[i] = preff[i-1]+pref[i-1]; } //for(int i=0;i<=n;i++) cout<<pref[i]<<" "; cin>>q; bool p = false; 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)); rez = 0; l--; r--; long long z = 0; int l1 = l; int r1 = l1+ma-2; int rez1 =(r1-l1+1)*pref[r1+1]-(preff[r1+1]-preff[l1]); int r2 = r; int l2 = r2-ma+2; int rez2 =-(r2-l2+1)*pref[l2]+(preff[r2+2]-preff[l2+1]); int u = (r-l+1)-(r1-l1+1)-(r2-l2+1); int rez3 = ma*(pref[l2]-pref[r1+1]); rez+=rez1; rez+=rez2; rez+=rez3; cout<<rez<<endl; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:43:12: warning: unused variable 'z' [-Wunused-variable]
   43 |  long long z = 0;
      |            ^
Main.cpp:50:6: warning: unused variable 'u' [-Wunused-variable]
   50 |  int u = (r-l+1)-(r1-l1+1)-(r2-l2+1);
      |      ^
Main.cpp:27:7: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   27 |  bool p = false;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...