小沙の赌气

题目

思路

首先将小沙和小雅的通关数都置为0,每输入一次两人获得的道具,都按左边界从小打到排序,若左边界小于等于通关数,则将通关数变为max(通关数,右边界),并将该道具移除,直到不满足条件。因此我们可以用优先队列来存储数据。

代码

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>

using namespace std;
#define _CRT_SECURE_NO_WARNINGS 1
#define ll long long
#define pub push_back
#define pob pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define inf 2e9
#define llf 1e19
#define endl "\n"
const ll mod = 1e9 + 7;

ll qpow(ll base, ll power)
{
	ll res = 1;
	while (power > 0)
	{
		if (power & 1) res = base * res % mod;
		power >>= 1;
		base = base * base % mod;
	}
	return res;
}

ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

double dis(double x, double y, double x1, double y1)
{
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}
double dis1(double x, double y, double z, double x1, double y1, double z1)
{
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1) + (z - z1) * (z - z1));
}
double chaji(double x1, double x2, double y1, double y2)
{
	return x1 * y2 - x2 * y1;
}

ll n;
ll ans1, ans2;
struct str
{
	ll l, r;
}sa[100010], ya[100010];
priority_queue<pll, vector<pll>, greater<pll>>q1;
priority_queue<pll, vector<pll>, greater<pll>>q2;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	ll i;
	pll p;
	cin >> n;
	for (i = 0; i < n; i++) cin >> sa[i].l >> sa[i].r;
	for (i = 0; i < n; i++) cin >> ya[i].l >> ya[i].r;
	for (i = 0; i < n; i++)
	{
		p = make_pair(sa[i].l, sa[i].r);
		q1.push(p);
		while (q1.size() && q1.top().first <= ans1 + 1)
		{
			ans1 = max(ans1, q1.top().second);
			q1.pop();
		}

		p = make_pair(ya[i].l, ya[i].r);
		q2.push(p);
		while (q2.size() && q2.top().first <= ans2 + 1)
		{
			ans2 = max(ans2, q2.top().second);
			q2.pop();
		}

		if (ans1 == ans2)
		{
			cout << "win_win!" << endl;
            cout << ans1 - ans2 << endl;
		}
		else if (ans1 > ans2)
		{
			cout << "sa_win!" << endl;
			cout << ans1 - ans2 << endl;
		}
		else if (ans1 < ans2)
		{
			cout << "ya_win!" << endl;
			cout << ans2 - ans1 << endl;
		}
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值