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>
using namespace std;
const int N = 5e5 + 10;
struct mov{
int t,loc;
} a[N];
int n,m;
signed main(){
iostream::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
cin >> n >> m;
vector<pair<int,int>> a(m);
for(int i = 0;i<m;i++){
cin >> a[i].first;
}
for(int i =0 ;i<m;i++){
cin >> a[i].second;
}
sort(a.begin(),a.end(),[&](pair<int,int> a,pair<int,int> b){
return a.first < b.first||(a.first == b.first && a.second > b.second);
});
a.erase(unique(a.begin(),a.end()), a.end());
m = a.size();
// int idxx[m];
// for(int i = 0;i<m;i++)
// cout << a[i].first << " ";
// cout << "\n";
// for(int i = 0;i<m;i++)
// cout << a[i].second << " ";
// cout << "\n";
int ans = 1e9;
for(int i = 0;i<10000;i++){
vector<int> arms;
for(int i = 0;i<m;i++){
int idx = -1;
vector<int> vec;
for(int j = 0;j<(int)arms.size();j++){
int e = arms[j];
if(abs(a[e].second - a[i].second) <= abs(a[e].first - a[i].first)){
vec.push_back(j);
}
}
if(vec.size() == 0){
arms.push_back(i);
}
else{
idx = vec[(rng()%(int)vec.size())];
arms[idx] = i;
}
}
ans = min(ans,(int)arms.size());
}
cout << ans << "\n";
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |