Submission #1135200

#TimeUsernameProblemLanguageResultExecution timeMemory
1135200ByeWorldAdvertisement 2 (JOI23_ho_t2)C++20
23 / 100
2094 ms5444 KiB
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<int,pii> ipii;
typedef pair<pii,pii> ipiii;
const int MAXN = 5e5+30;
const int SQRT = 610;
const int MAXA = 5e5+10;
const int MOD = 1e6+7;
const int INF = 2e9+10;
const int LOG = 19;
const ld EPS = 1e-12;
void chmx(int &a, int b){ a = max(a,b); }
void chmn(int &a, int b){ a = min(a,b); }

int n, le[MAXN], ri[MAXN], a[MAXN];
pii x[MAXN]; // influence le ri
int ANS;
vector <pii> vec;

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n; ANS = n;
    for(int i=1; i<=n; i++){
        cin>>x[i].fi>>x[i].se;
    }
    sort(x+1, x+n+1);
    for(int i=1; i<=n; i++){ 
        le[i] = x[i].se-x[i].fi; ri[i] = x[i].fi+x[i].se;
    }
    for(int p=0; p<(1<<n); p++){
        for(int i=0; i<n; i++)
            a[i+1] = (p>>i)&1;
        bool can = 1;
        for(int i=1; i<=n; i++){
            if(a[i]) continue;
            bool nw = 0;
            for(int j=1; j<=i-1; j++){
                if(!a[j]) continue;
                if(ri[j] >= ri[i]) nw = 1;
            }
            for(int j=i+1; j<=n; j++){
                if(!a[j]) continue;
                if(le[j] >= le[i]) nw = 1;
            }
            can &= nw;
        }
        if(can) chmn(ANS, __builtin_popcount(p));
    }
    // for(int i=1; i<=n; i++){
    //     while(!vec.empty() && vec.back().fi <= le[i])
    //         vec.pop_back();
    //     vec.pb({le[i], i});
    //     int tot = vec.size();
    //     int mx = -INF;
    //     for(auto [x, id] : vec) chmx(mx, ri[id]);

    //     for(int j=i+1; j<=n; j++){
    //         if(ri[j] > mx) tot++;
    //     }
    //     // cout << i << ' ' << tot << " tot\n";
    //     chmn(ANS, tot);
    // }

    cout << ANS << '\n';
}   
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...