#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll=long long;
using pll=array<ll,2>;
const ll inf=1e18;
const int N=2e5+5;
int n,q;
ll a[N],cnt[N];
void solve(){
ll ret=0,cur=0;
for(int i=1;i<=n;i++) cnt[i]=0;
for(int i=1;i<=n;i++){
if(a[i]&1) cnt[i]+=1;
cnt[min(n,2*i-1)]-=a[i]/2;
ret+=a[i]/2;
}
for(int i=1;i<=n;i++){
cur+=cnt[i];
if(cur<0){
ll d=(-cur+2)/3;
cur+=3*d;
ret-=d;
}
}
cout<<ret<<"\n";
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i,c,T=1;T<=q;T++){
cin>>i>>c;
a[i]+=c;
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
10 ms |
368 KB |
Output is correct |
7 |
Correct |
10 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
352 KB |
Output is correct |
9 |
Correct |
10 ms |
368 KB |
Output is correct |
10 |
Correct |
10 ms |
340 KB |
Output is correct |
11 |
Correct |
10 ms |
372 KB |
Output is correct |
12 |
Correct |
10 ms |
372 KB |
Output is correct |
13 |
Correct |
10 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
10 ms |
368 KB |
Output is correct |
7 |
Correct |
10 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
352 KB |
Output is correct |
9 |
Correct |
10 ms |
368 KB |
Output is correct |
10 |
Correct |
10 ms |
340 KB |
Output is correct |
11 |
Correct |
10 ms |
372 KB |
Output is correct |
12 |
Correct |
10 ms |
372 KB |
Output is correct |
13 |
Correct |
10 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
17 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
340 KB |
Output is correct |
19 |
Correct |
16 ms |
376 KB |
Output is correct |
20 |
Correct |
16 ms |
340 KB |
Output is correct |
21 |
Correct |
11 ms |
368 KB |
Output is correct |
22 |
Correct |
16 ms |
372 KB |
Output is correct |
23 |
Correct |
13 ms |
340 KB |
Output is correct |
24 |
Correct |
11 ms |
360 KB |
Output is correct |
25 |
Correct |
16 ms |
412 KB |
Output is correct |
26 |
Correct |
14 ms |
340 KB |
Output is correct |
27 |
Correct |
12 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
288 KB |
Output is correct |
2 |
Correct |
11 ms |
340 KB |
Output is correct |
3 |
Correct |
43 ms |
708 KB |
Output is correct |
4 |
Execution timed out |
4043 ms |
3452 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
368 KB |
Output is correct |
2 |
Correct |
17 ms |
340 KB |
Output is correct |
3 |
Correct |
17 ms |
384 KB |
Output is correct |
4 |
Correct |
11 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
4075 ms |
3448 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
10 ms |
368 KB |
Output is correct |
7 |
Correct |
10 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
352 KB |
Output is correct |
9 |
Correct |
10 ms |
368 KB |
Output is correct |
10 |
Correct |
10 ms |
340 KB |
Output is correct |
11 |
Correct |
10 ms |
372 KB |
Output is correct |
12 |
Correct |
10 ms |
372 KB |
Output is correct |
13 |
Correct |
10 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
17 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
340 KB |
Output is correct |
19 |
Correct |
16 ms |
376 KB |
Output is correct |
20 |
Correct |
16 ms |
340 KB |
Output is correct |
21 |
Correct |
11 ms |
368 KB |
Output is correct |
22 |
Correct |
16 ms |
372 KB |
Output is correct |
23 |
Correct |
13 ms |
340 KB |
Output is correct |
24 |
Correct |
11 ms |
360 KB |
Output is correct |
25 |
Correct |
16 ms |
412 KB |
Output is correct |
26 |
Correct |
14 ms |
340 KB |
Output is correct |
27 |
Correct |
12 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
10 ms |
288 KB |
Output is correct |
30 |
Correct |
11 ms |
340 KB |
Output is correct |
31 |
Correct |
43 ms |
708 KB |
Output is correct |
32 |
Execution timed out |
4043 ms |
3452 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |