Submission #793997

# Submission time Handle Problem Language Result Execution time Memory
793997 2023-07-26T08:34:26 Z 곰(#10095) Triangle Collection (CCO23_day2problem3) C++17
5 / 25
4000 ms 1896 KB
#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,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++) cnt[min(n,2*i-1)]+=a[i]/2;
	for(int i=1;i<=n;i++){
		if(a[i]&1) cur++;
		// cur + 2 * d >= cnt[i] - d
		// d >= (cnt [i] - cur) / 3
		if(cur<cnt[i]){
			ll d=(cnt[i]-cur+2)/3;
			cnt[i]-=d;
			cur+=2*d;
		}
		ret+=cnt[i];
		cur-=cnt[i];
	}
	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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 11 ms 340 KB Output is correct
7 Correct 11 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 11 ms 364 KB Output is correct
10 Correct 14 ms 368 KB Output is correct
11 Correct 11 ms 360 KB Output is correct
12 Correct 13 ms 356 KB Output is correct
13 Correct 15 ms 356 KB Output is correct
14 Correct 7 ms 348 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 11 ms 340 KB Output is correct
7 Correct 11 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 11 ms 364 KB Output is correct
10 Correct 14 ms 368 KB Output is correct
11 Correct 11 ms 360 KB Output is correct
12 Correct 13 ms 356 KB Output is correct
13 Correct 15 ms 356 KB Output is correct
14 Correct 7 ms 348 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 352 KB Output is correct
2 Correct 11 ms 340 KB Output is correct
3 Correct 36 ms 712 KB Output is correct
4 Execution timed out 4078 ms 1896 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 360 KB Output is correct
2 Incorrect 16 ms 340 KB Output isn't correct
3 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 11 ms 340 KB Output is correct
7 Correct 11 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 11 ms 364 KB Output is correct
10 Correct 14 ms 368 KB Output is correct
11 Correct 11 ms 360 KB Output is correct
12 Correct 13 ms 356 KB Output is correct
13 Correct 15 ms 356 KB Output is correct
14 Correct 7 ms 348 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -