#include #include typedef long long int int64; typedef struct segmentNode{ int v; struct segmentNode *left,*right; } segNode; segNode* newNode(void){ segNode *res=(segNode *)malloc(sizeof(segNode)); res->v=0; res->left=NULL; res->right=NULL; return res; } int eval(segNode *p){ return p==NULL?0:p->v; } segNode* update(segNode *p,int64 l,int64 r,const int64 index,const int v){ if(p==NULL) p=newNode(); if(l==index && r==index){ p->v+=v; return p; } int64 m=(l+r)/2; if(index<=m){ p->left=update(p->left,l,m,index,v); } else { p->right=update(p->right,m+1,r,index,v); } p->v=eval(p->left)+eval(p->right); return p; } int64 search(segNode *p,int64 l,int64 r,int k){ if(l==r){ return eval(p)>=k?l:-1; } if(eval(p)left)right,m+1,r,k-eval(p->left)):search(p->left,l,m,k); } void run(void){ int q,k; scanf("%d%d",&q,&k); int64 l=0; int64 r=1000000000000000000LL; segNode *root=NULL; while(q--){ int c; scanf("%d",&c); if(c==1){ int64 v; scanf("%lld",&v); root=update(root,l,r,v,1); } else if(eval(root)