0
点赞
收藏
分享

微信扫一扫

牛客白月赛22【题解】

全栈顾问 2022-05-04 阅读 76

目录

操作序列【STL维护】

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
string s,a; 
int main(void)
{
	int t; cin>>t;
	getline(cin,s);
	while(t--) 
	{
		getline(cin,s);
		stringstream l(s);
		vector<int>ve;
		while(l>>a) ve.push_back(stoi(a));
		if(ve.size()==1)
		{
			if(ve[0]==-1)
			{
				auto temp=mp.begin();
				if(temp==mp.end()) puts("skipped");
				else
				{
					 cout<<temp->second<<'\n';
					 mp.erase(temp);
				}
			}
			else
			{
				if(mp.count(ve[0])) cout<<mp[ve[0]]<<'\n';
				else cout<<0<<'\n'; 
			}
		}else
		{
			bool flag=1;
			for(int i=ve[0]-30;i<=ve[0]+30;i++)
				if(mp.count(i)&&mp[i]>0) flag=0;
			if(flag) mp[ve[0]]+=ve[1];
		}
	}
	return 0;
}
举报

相关推荐

0 条评论