# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476164 | 2021-09-25T07:22:18 Z | quackson | Addk (eJOI21_addk) | C++14 | 129 ms | 1932 KB |
#include <bits/stdc++.h> #pragma GCC diagnostic warning "-std=c++11" using namespace std; int main(){ long long n, k; cin >> n >> k; long long arr[n + 1]; for(int i = 1; i <= n; i++){ cin >> arr[i]; } long long prefix[n + 1] = {0}; long long prefix2[n + 1] = {0}; for(int i = 1; i <= n; i++){ prefix[i] = prefix[i - 1] + arr[i]; prefix2[i] = prefix2[i - 1] + arr[i] * i; } int q; cin >> q; while(q--){ int oneOrTwo; cin >> oneOrTwo; if(oneOrTwo == 1){ int smth; cin >> smth; } else{ int l, r, m; cin >> l >> r >> m; m = min(r - l + 2 - m, m); int a = (prefix2[l + m - 1] - prefix2[l - 1]) - (prefix[l + m - 1] - prefix[l - 1]) * (l - 1); int b = m * (prefix[r - m] - prefix[l + m - 1]); int c = (r + 1) * (prefix[r] - prefix[r - m]) - (prefix2[r] - prefix2[r - m]); cout << a + b + c << endl; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 3 ms | 204 KB | Output is correct |
3 | Incorrect | 6 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 60 ms | 932 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 129 ms | 1932 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |