#include <bits/stdc++.h>
using namespace std;
int length;
bool can(int a,int b,int c,int d){
//pos1,val,pos2,val
return (long double)(a+((long double)(length)/(long double)b))>(long double)(c+((long double)(length)/(long double)d));
}
int main() {
int no_of_input;
int input1,input2;
vector<pair<int,int> > vect1;
cin >> length >> no_of_input;
for(int i=0;i<no_of_input;i++){
cin >> input1 >> input2;
vect1.push_back({input1,input2});
}
sort(vect1.begin(),vect1.end());
vector<int> dp(no_of_input,1);
for(int i=0;i<no_of_input;i++){
for(int j=i+1;j<no_of_input;j++){
if(vect1[i].first<vect1[j].first){
if(can(vect1[i].first,vect1[i].second,vect1[j].first,vect1[j].second)==true){
//cout << i << " " << j << "\n";
//cout << vect1[i].first << " "<< vect1[j].first << "\n";
dp[j]= max(dp[j],dp[i]+1);
}
}
}
}
int maxx = 0;
for(int i=0;i<dp.size();i++){
//cout << dp[i] << " ";
maxx = max(maxx,dp[i]);
}
//cout << "\n";
cout << maxx;
}
Compilation message
walking.cpp: In function 'int main()':
walking.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<dp.size();i++){
~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |