跳到正文

题解

题解:AT_abc379_d [ABC379D] Home Garden

majingxu3约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年11月10日
收录
2025年12月12日
更新
2026年11月18日
篇幅
约 1 分钟

版本

  1. v1当前

一道大水题,暴力就能过,数据超弱,配当D吗,开一个a数组,每种一个便cnt++,移除时head++就行

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],cnt,head=1;
signed main(){
	int q;
	cin>>q;
	while(q--){
		int opt;
		cin>>opt;
		if(opt==1){
			a[++cnt]=0;
		}
		if(opt==2){
			int t;
			cin>>t;
			for(int i=head;i<=cnt;i++){
				a[i]+=t;
			}
		}
		if(opt==3){
			int h,ans=0;
			cin>>h;
			for(int i=head;i<=cnt;i++){
				if(a[i]>=h){
					head++;
					ans++;
				}
			}
			cout<<ans<<'\n';
		}
	}
} 
原文