哼哼啊啊啊啊啊啊啊!!!!!
这个代码到底哪里错了呀……
有没有大佬解析一下谢谢Orz
QAQ QAQ QAQ QAQ
(10pts)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
ll l,r;
ll len(){return 1ll*r-l+1;}
ll sum(){return 1ll*(l+r)*(r-l+1)/2;}
}Stack[10000007];
int top=0;
ll sum(ll l,ll r){return 1ll*(l+r)*(r-l+1)/2;}
int main(){
int n,t,L,R,k,Sum=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>t;
if(t==1){
cin>>L>>R;
top++;
Stack[top].l=L;
Stack[top].r=R;
}
else{
cin>>k;
while(k&&top){
if(k>=Stack[top].len()){
Sum+=Stack[top].sum();
k-=Stack[top].len();
top--;
}
else{
Sum+=sum(Stack[top].r-k+1,Stack[top].r);
Stack[top].r-=k;
break;
}
}
cout<<Sum;
}
}
return 0;
}