답안 #793993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793993 2023-07-26T08:32:15 Z 곰(#10095) Triangle Collection (CCO23_day2problem3) C++17
0 / 25
37 ms 680 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++){
		cur+=a[i]&1;
		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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Incorrect 11 ms 356 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Incorrect 11 ms 356 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 340 KB Output is correct
2 Correct 11 ms 356 KB Output is correct
3 Incorrect 37 ms 680 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Incorrect 11 ms 356 KB Output isn't correct
7 Halted 0 ms 0 KB -