题解:AT_abc457_g [ABC457G] Catch All Apples
NoneOfTheAbove · · 题解
luogu link
atcoder link
Solution
神秘题目。
一个机器人想从第
,移项可得到:
把机器人和苹果看成二维平面上的点,坐标为
Code
:::success[code]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef double db;
typedef __int128 i128;
const ll inf=9e18,maxn=3e5+1;
const i128 Inf=1e35;
ll n,t,x;
struct point
{
ll x,y;
bool operator<(point p) const
{
return ((x==p.x)?(y<p.y):(x<p.x));
}
}a[maxn];
multiset<ll> ms;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t>>x;
a[i].x=t-x,a[i].y=t+x;
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
{
auto it=ms.upper_bound(a[i].y);
if(it==ms.begin()) ms.insert(a[i].y);
else
{
it--;
ms.erase(it);
ms.insert(a[i].y);
}
}
cout<<ms.size();
}
:::