# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
556067 |
2022-05-02T10:10:46 Z |
Skurrl |
Addk (eJOI21_addk) |
C++17 |
|
1950 ms |
5756 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 100005
#define MOD 1000000007
#define endl '\n'
#define all(x) x.begin(), x.end()
typedef long long int ll;
const ll inf = 1e17;
void solve()
{
int n, k; cin >> n >> k;
vector<ll> arr(n + 1), pref(n + 1);
for (int i = 1; i <= n; ++i)
{
cin >> arr[i];
pref[i] = pref[i - 1] + arr[i];
}
int q; cin >> q;
while(q--)
{
int type; cin >> type;
if(type == 1) for(int i = 1; i <= k; ++i) { int smt; cin >> smt; }
else
{
int l, r, m; cin >> l >> r >> m;
ll res = 0;
if(min(r - m - l + 2, 2 * m - 2) == (r - m - l + 2))
for(int i = l; i <= r - m + 1; ++i)
res += pref[i + m - 1] - pref[i - 1];
else
{
for (int i = l, cnt = 1; i < l + m; ++i, ++cnt) res += cnt * arr[i];
for(int i = r, cnt = 1; i > r - m; --i, ++cnt) res += cnt * arr[i];
res += m * (pref[r - m] - pref[l + m - 1]);
}
cout << res << endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//ll t; cin >> t;
//while(t--)
solve();
}
/*
1 2 3 4 5 6 7 8 9, m = 4
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
5 6 7 8
6 7 8 9
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
340 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
7 ms |
452 KB |
Output is correct |
7 |
Correct |
9 ms |
596 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
23 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
844 KB |
Output is correct |
2 |
Correct |
157 ms |
1124 KB |
Output is correct |
3 |
Correct |
286 ms |
1520 KB |
Output is correct |
4 |
Correct |
1049 ms |
2380 KB |
Output is correct |
5 |
Correct |
1950 ms |
3980 KB |
Output is correct |
6 |
Correct |
1747 ms |
5756 KB |
Output is correct |
7 |
Correct |
1477 ms |
5608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
237 ms |
1720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |