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;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
fastIO;
int n, m;
cin >> n >> m;
pii z[m];
for(int i = 0 ; i < m; i ++ ){
cin >> z[i].fi;
}
for(int i = 0 ; i < m; i ++ ){
cin >> z[i].se;
}
sort(z, z + m);
int answer = 1;
int cur;
int T;
int las;
for(int i = 1 ; i < m; i ++ ){
for(int j = i - 1; j >= 0 ; j -- ){
if(z[i].fi - z[j].fi < abs(z[i].se - z[j].se)){
T = z[i].fi - z[j].fi;
vector<int> res;
las = z[i].fi;
for(int k = j + 1; k < i ; k ++ ){
if(abs(z[k].se - z[i].se) > T && abs(z[k].se - z[j].se) > T){
res.push_back(z[k].se);
}
}
cur = 2;
sort(res.begin(), res.end());
for(auto x : res){
if(x - las > T){
las = x;
cur ++ ;
}
}
answer = max(answer, cur);
}
}
}
cout << answer << "\n";
return 0;
}
# | 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... |