# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
474785 | 2021-09-19T17:22:58 Z | fuad27 | Addk (eJOI21_addk) | C++17 | 150 ms | 2308 KB |
#include<bits/stdc++.h> #define int long long using namespace std; int32_t main () { int n, k; cin >> n >> k; int arr[n+1], prefix1[n+1] = {0}, prefix2[n+1] = {0}; for(int i = 1;i<=n;i++) { cin >> arr[i]; prefix1[i] = prefix1[i-1] + arr[i]; prefix2[i] = prefix2[i-1] + arr[i]*i; } int q; cin >> q; while(q--) { int k; cin >> k; if(k == 1) { } else { int ans = 0; int l, r, m; cin >> l >> r >> m; m = min(r-l-m + 2, m); int a = (prefix2[l+m-1] - prefix2[l-1])-(prefix1[l+m-1] - prefix1[l-1])*(l-1); int b = (prefix1[r-m] - prefix1[l+m-1])*m; int c = (prefix1[r] - prefix1[r-m])*(r+1) - (prefix2[r] - prefix2[r-m]); cout<<a+b+c<<endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 1168 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 150 ms | 2308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |