1. Home
  2. Record
  1. Login
  2. Language
    1. English
    2. 한국어
    3. 简体中文
    4. 正體中文

CC20260077

UID: 1718, Registered at 2023-10-5 9:14:07, last login at 2024-11-12 10:17:58, currently offline.

Solved 33 problems, RP: 178.67 (No. 244)

  • Bio

    //Subarray Sum
    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    struct div
    {
    	int l,r;
    	bool inv;
    	bool operator<(div y)
    	{
    		if(l==y.l)return r<y.r;
    		return l<y.l;
    	}
    }a[100002];
    
    int main()
    {
    	int n,l=-1e9-7,cnt=0;
    	cin >> n;
    	for(int i=1;i<=n;i++)
    	{
    		int x,l_;
    		cin >> x >> l_;
    		a[i].l=x-l_;
    		a[i].r=x+l_;
    		//cout << l << " " << a[i].l << " " << a[i].r << endl;
    	}
    	sort(a+1,a+n+1);
    	int f=0;
    	do
    	{
    		f=0;
    		for(int i=1;i<=n;i++)
    		{
    			if(!a[i].inv)
    			{
    				if(a[i].r<l)
    				{
    					a[i-1].inv=1;
    					f=1;
    					//cout << i << endl;
    				}
    				l=a[i].r;
    			}
    		}
    	}while(f);
    	l=-1e9;
    	for(int i=1;i<=n;i++)
    	{
    		if(!a[i].inv&&a[i].l>=l)
    		{
    			l=a[i].r;
    			cnt++;
    			//cout << i << " ";
    		}
    		//cout << l << " " << a[i].l << " " << a[i].r << endl;
    	}
    	cout << cnt;
    	return 0;
    }
    
  • Recent Activities

    • 10.6 提高组模拟赛 OI
    • 10.4 提高组模拟赛 OI
    • 国庆提高组30题(1~3号) IOI
    • 10.5 练习 IOI
    • 保送生第15周 杂题选讲 Assignment
    • 保送生第14周 反演 Assignment
    • 保送生第12周 FFT 多项式 Assignment
    • 保送生第七周 启发式合并 Assignment
    • 20240604集训 IOI
    • 20240528集训 IOI
    • 20240521集训 IOI
    • CSP-J 前两题真题汇总 Ledo
    • 20231010集训 OI
41
Submitted
33
Accepted
0
Solutions Liked

Status

  • Judging Queue
  • Service Status

Development

  • Open Source
  • API

Support

  • Help
  • QQ Group
  1. About
  2. Contact Us
  3. Privacy
  4. Terms of Service
  5. Copyright Complaint
  6. Language
    1. English
    2. 한국어
    3. 简体中文
    4. 正體中文
  7. Legacy mode
  8. Theme
    1. Light
    2. Dark
  1. 粤ICP备2021104657号
  2. Worker 0, 11ms
  3. Powered by Hydro v4.14.1 Community

Don't have an account?

By signing up a HFOJ universal account, you can submit code and join discussions in all online judging services provided by us.

CLOSE

SIGN IN

Using your HFOJ universal account

Forgot password or username?