# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
476172 | 2021-09-25T07:32:02 Z | quackson | Addk (eJOI21_addk) | C++17 | 273 ms | 4060 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]; long long prefix[n + 1] = {0}; long long prefix2[n + 1] = {0}; for(int i = 1; i <= n; i++){ cin >> arr[i]; prefix[i] = prefix[i - 1] + arr[i]; prefix2[i] = prefix2[i - 1] + arr[i] * i; } long long q; cin >> q; while(q--){ long long oneOrTwo; cin >> oneOrTwo; if(oneOrTwo == 1){ int smth; cin >> smth; } else{ long long l, r, m; cin >> l >> r >> m; m = min(r - l + 2 - m, m); long long a = (prefix2[l + m - 1] - prefix2[l - 1]) - (prefix[l + m - 1] - prefix[l - 1]) * (l - 1); long long b = (prefix[r - m] - prefix[l + m - 1]) * m; long long c = (prefix[r] - prefix[r - m]) * (r + 1) - (prefix2[r] - prefix2[r - m]); cout << a + b + c << endl; } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 3 ms | 204 KB | Output is correct |
3 | Correct | 5 ms | 332 KB | Output is correct |
4 | Correct | 8 ms | 332 KB | Output is correct |
5 | Correct | 10 ms | 332 KB | Output is correct |
6 | Correct | 13 ms | 468 KB | Output is correct |
7 | Correct | 17 ms | 512 KB | Output is correct |
8 | Correct | 21 ms | 504 KB | Output is correct |
9 | Correct | 26 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 920 KB | Output is correct |
2 | Correct | 86 ms | 1328 KB | Output is correct |
3 | Correct | 114 ms | 1788 KB | Output is correct |
4 | Correct | 199 ms | 2928 KB | Output is correct |
5 | Correct | 270 ms | 4060 KB | Output is correct |
6 | Correct | 273 ms | 4008 KB | Output is correct |
7 | Correct | 259 ms | 3900 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 153 ms | 2392 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |