两关 re求助
查看原帖
两关 re求助
486799
BlackPanda楼主2023/8/28 20:44
#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N = 2e5 + 10;

int c, q;
int op, x;
int a[N];
set<int> se;
int cnt = 1;
int tmp = 0;
int maxn = -1;

void solve()
{
	cin >> c >> q;
	while (q -- )
	{
		cin >> op;
		if (op == 1)
		{
			cin >> x;
			se.insert(x);
			maxn = max(x, maxn);
			for (int i = 1; i <= x; i ++ )	a[cnt] = i, cnt ++ ;
		}
		else if (op == 2)
		{
			cin >> x;
			for (int i = tmp + 1; i <= tmp + x; i ++ )
			{
				if (a[i] == maxn)
				{
					se.erase(a[i]);
					maxn = *se.rbegin();
				}
			}
			tmp += x;
		}
		else if (op == 3)
		{
			cin >> x;
			//for (int i = 1; i <= cnt; i ++ )	cout << a[i] << " ";
			cout << a[tmp + x] << endl;
		}
		else
		{
			cout << maxn << endl;
		}
	}
	return ;
}

signed main()
{
	ios::sync_with_stdio(0);
	solve();
	return 0;
}

15分

2023/8/28 20:44
加载中...