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;
int n,m;
pair < int , int > p[5];
int main(){
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>p[i].first>>p[i].second;
}
int x = abs(p[0].first-p[1].first);
int mn = 1000000009;
if(x%p[0].second == 0) mn = x/p[0].second;
if(m == 3){
int y = abs(p[1].first-p[2].first);
int xy = abs(p[0].first-p[2].first);
if(y%p[2].second == 0 && xy%p[0].second == 0)
mn = min(mn,xy/p[0].second+y/p[2].second);
}
if(mn == 1000000009) cout<<-1<<endl;
else cout<<mn<<endl;
}
# | 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... |