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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
int dp[505], l, n;
pi a[505];
bool ok(int p, int q){
return (a[p].first < a[q].first) &&
(l * a[q].second + a[p].first * a[p].second * a[q].second > l * a[p].second + a[q].first * a[p].second * a[q].second);
}
int main(){
scanf("%d %d",&l,&n);
for(int i=0; i<n; i++){
scanf("%d %d",&a[i].first, &a[i].second);
}
sort(a, a+n);
for(int i=n-1; i>=0; i--){
dp[i] = 1;
for(int j=i+1; j<n; j++){
if(ok(i,j)) dp[i] = max(dp[i], dp[j] + 1);
}
}
printf("%d",*max_element(dp, dp+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... |