Submission #935204

#TimeUsernameProblemLanguageResultExecution timeMemory
935204Rux007Advertisement 2 (JOI23_ho_t2)C++14
0 / 100
2071 ms13304 KiB
#include <bits/stdc++.h> using namespace std; const int nmax = 500005; int n, a[nmax], sol[nmax], mini = INT_MAX, fr[nmax], rasp[nmax]; pair<int, int> v[nmax]; bool verif(int k) { for(int i = 1; i <= n; i ++) rasp[i] = 0; for(int i = 1; i <= k; i ++) for(int j = 1; j <= n; j ++) if(abs(v[sol[i]].first - v[j].first) <= v[sol[i]].second - v[j].second) rasp[j] = 1; int ok = 1; for(int i = 1; i <= n; i ++) if(!rasp[i]) ok = 0; return (ok); } void backy(int poz, int k, int &p) { if(poz > k) { if(verif(k)) { p = 1; return; } } else { for(int i = 1; i <= n; i ++) if(!fr[i]) { fr[i] = 1; sol[poz] = i; backy(poz + 1, k, p); fr[i] = 0; } } } int main() { cin >> n; for(int i = 1; i <= n; i ++) cin >> v[i].first >> v[i].second; int st = 1, dr = n; while(st < dr) { int mij = (st + dr) / 2; int p = 0; backy(1, mij, p); if(p) { dr = mij - 1; mini = min(mini, mij); } else st = mij + 1; } cout << mini; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...