求助 模拟栈
查看原帖
求助 模拟栈
464094
NEO_bone楼主2021/9/20 19:21

**惨不忍睹 **

#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>
using namespace std;
int S[10000000],now;
int n,l,r;int wh;long long k,ans;
int main(){
	cin>>n;
	while(n){
		cin>>wh;
		if(wh==1){
			cin>>l>>r;
			for(int i=l;i<=r;i++)
			{
				now++;
				S[now]=i;
			}
		}
		
		else{
			cin>>k;
			for(long long i=1;i<=k;i++)
			{
				ans+=S[now];
				now--;
			}
			cout<<ans<<endl;ans=0;
		}
		n--;
	}
	return 0;
}
2021/9/20 19:21
加载中...