# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1096540 |
2024-10-04T17:29:44 Z |
andrewp |
Addk (eJOI21_addk) |
C++14 |
|
2000 ms |
4124 KB |
//Dedicated to my love, ivaziva
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
using ll = int64_t;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define dbg(x) cerr<<#x<<": "<<x<<'\n';
#define dbga(A,l_,r_){for(int i_=l_;i_<=r_;i_++)cerr<<A[i_]<<' ';cerr<<'\n';}
#define dbgv(a_){for(auto x_:a_) cerr<<x_<<' ';cerr<<'\n';}
const int maxn = 1e5 + 20;
int n, k, a[maxn];
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.tie(nullptr); cerr.tie(nullptr);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int q;
cin >> q;
while (q--) {
int tp;
cin >> tp;
if (tp == 1) {
int x;
cin >> x;
continue;
}
int l, r, m;
cin >> l >> r >> m;
int sum = 0, c = min(r - l + 1 - m + 1, m);
for (int i = l; i <= (l + c - 2); i++) {
sum += a[i] * (i - l + 1);
}
for (int i = r; i >= (r - c + 2); i--) {
sum += a[i] * (r - i + 1);
}
for (int i = l + c - 1; i <= r - c + 1; i++) {
sum += a[i] * c;
}
cout << sum << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
484 KB |
Output is correct |
5 |
Correct |
7 ms |
604 KB |
Output is correct |
6 |
Correct |
10 ms |
632 KB |
Output is correct |
7 |
Correct |
13 ms |
848 KB |
Output is correct |
8 |
Correct |
17 ms |
604 KB |
Output is correct |
9 |
Correct |
33 ms |
792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
1216 KB |
Output is correct |
2 |
Correct |
292 ms |
1740 KB |
Output is correct |
3 |
Correct |
484 ms |
2268 KB |
Output is correct |
4 |
Correct |
1543 ms |
3672 KB |
Output is correct |
5 |
Execution timed out |
2039 ms |
4124 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
944 ms |
3080 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |