| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 797764 | n3rm1n | Advertisement 2 (JOI23_ho_t2) | C++17 | 150 ms | 20072 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 5e5 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, a, b;
vector < pair < int, int > > v, g;
void read()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size()-1; ++ i)
    {
        if(v[i].first != v[i+1].first)
            g.push_back(v[i]);
    }
    g.push_back(v[v.size()-1]);
}
int cnt[MAXN];
void solve()
{
    n = g.size();
    int maxx = -1e9;
    for (int i = 0; i < n; ++ i)
    {
        if(maxx >= g[i].first + g[i].second)
            cnt[i] ++;
        maxx = max(maxx, g[i].first + g[i].second);
    }
    maxx = -1e9;
    for (int i = n-1; i >= 0; -- i)
    {
        if(maxx >= g[i].second - g[i].first)
            cnt[i] ++;
        maxx = max(maxx, g[i].second - g[i].first);
    }
    int ans = 0;
    for (int i = 0; i < n; ++ i)
        if(!cnt[i])ans ++;
    cout << ans << endl;
}
int main()
{
    speed();
    read();
    solve();
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
