# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1008980 |
2024-06-27T07:23:30 Z |
LilPluton |
Addk (eJOI21_addk) |
C++14 |
|
2000 ms |
1616 KB |
#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
#define OPT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define intt long long
#define arr array
#define vll vector<ll>
#define fi first
#define se second
#define rep(i,j,k) for(int i = j; i <= k; ++i)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define endll '\n'
using namespace std;
const intt N = 2e5 + 6;
const intt mod = 1e9 + 7;
int a[N], t[N * 4];
int n;
vector<int> ft;
void init(int N)
{
n = N + 5;
ft.assign(n + 5, 0);
}
void add(int pos, int val)
{
for (pos = pos + 1; pos <= n; pos += pos & -pos) ft[pos] += val;
}
int get(int pos, int res = 0)
{
for (pos = pos + 1; pos > 0; pos -= pos & -pos) res += ft[pos];
return res;
}
signed main()
{
OPT
ll n, k;
cin >> n >> k;
init(n);
for(ll i = 1; i <= n; ++i)
cin >> a[i], add(i, a[i]);
ll q;
cin >> q;
while(q--)
{
ll t;
cin >> t;
if(t == 1)
{
ll p;
cin >> p;
}
else
{
ll l, r, m, ans = 0;
cin >> l >> r >> m;
for(ll i = l; i + m - 1 <= r; ++i)
{
ans += get(i + m - 1);
ans -= get(i - 1);
}
cout << ans << endll;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
11 ms |
348 KB |
Output is correct |
4 |
Correct |
25 ms |
348 KB |
Output is correct |
5 |
Correct |
44 ms |
536 KB |
Output is correct |
6 |
Incorrect |
72 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1156 ms |
848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2051 ms |
1616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |