이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pi;
typedef pair<long double, long long> pii;
long long l, n, t, v;
int dp[501][501];
pi d[501];
pii a[501];
int lcs(int al, int bl){
        if(al == 0 || bl == 0) return 0;
        if(dp[al][bl] != -1) return dp[al][bl];
        dp[al][bl] = max(lcs(al-1, bl), lcs(al, bl-1));
        if(d[al-1].second == a[bl-1].second) dp[al][bl] = max(dp[al][bl], lcs(al, bl-1)+1);
        return dp[al][bl];
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        memset(dp, -1, sizeof(dp));
        cin >> l >> n;
        for(int i = 0; i < n; i++){
                cin >> t >> v;
                d[i] = pi(t, i);
                a[i] = pii((long double)t+((long double)l/(long double)v), i);
        }
        sort(d, d+n);
        sort(a, a+n);
        reverse(a, a+n);
        cout << lcs(n, 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... |