# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
526120 |
2022-02-13T19:13:12 Z |
speedyArda |
Addk (eJOI21_addk) |
C++14 |
|
2000 ms |
6736 KB |
#include "bits/stdc++.h"
#define pb push_back
#define vll vector<long long>
#define vb vector<bool>
#define vi vector<int>
#define vs vector<string>
#define vpii vector< pair<int, int> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vvi vector< vector<int> >
#define ld long double
#define mp make_pair
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
const int MAXN = 1e5;
ll seg[MAXN * 4 + 5], in[MAXN + 5], pref[MAXN + 5];
void build(int v, int l, int r)
{
if(l == r)
{
seg[v] = in[l];
} else
{
int m = (l + r) / 2;
build(2 * v, l, m);
build(2 * v + 1, m + 1, r);
seg[v] = seg[v * 2] + seg[v * 2 + 1];
}
}
ll sum(int v, int l, int r, int tl, int tr)
{
if(tl > tr)
return 0;
if(l == tl && r == tr)
return seg[v];
int m = (l + r) / 2;
return sum(2 * v, l, m, tl, min(m, tr)) + sum(2 * v + 1, m + 1, r, max(tl, m + 1), tr);
}
int main()
{
FASTIO
int n, q, k;
cin >> n >> k;
for(int i = 1; i <= n; i++) {
cin >> in[i];
pref[i] = pref[i - 1];
pref[i] += in[i];
}
build(1, 1, n);
cin >> q;
while(q--)
{
int query;
cin >> query;
if(query == 1)
{
int a;
cin >> a;
continue;
}
int l, r, m;
cin >> l >> r >> m;
ll res = 0;
//36 Points
int tl = l, tr = l + m - 1;
while(tr <= r)
{
res += pref[tr] - pref[tl - 1];
tl++;
tr++;
}
cout << res << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
4 ms |
460 KB |
Output is correct |
5 |
Correct |
6 ms |
588 KB |
Output is correct |
6 |
Correct |
9 ms |
588 KB |
Output is correct |
7 |
Correct |
13 ms |
756 KB |
Output is correct |
8 |
Correct |
17 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
1524 KB |
Output is correct |
2 |
Correct |
228 ms |
2420 KB |
Output is correct |
3 |
Correct |
427 ms |
3408 KB |
Output is correct |
4 |
Correct |
1644 ms |
6204 KB |
Output is correct |
5 |
Execution timed out |
2071 ms |
6736 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
212 ms |
3184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |