MLE+TLE50分求助
查看原帖
MLE+TLE50分求助
720096
sdsdsf楼主2022/10/22 19:42
#include<bits/stdc++.h>
using namespace std;
const int N=5e8;
int a[N];
int main(){
	int n,to=1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int op,x,y;
		cin>>op;
		if(op==1)
		{
			cin>>x>>y;
			for(int j=x;j<=y;j++)
			{
				a[to]=j;
				to++;
			}
		}
		if(op==2)
		{
			int l=0;
			cin>>x;
			for(int j=0;j<x;j++)
			{
				l+=a[to-1];
				to--;
			}
			cout<<l<<endl;
		}
	}
	return 0;
}
2022/10/22 19:42
加载中...