Submission #639367

#TimeUsernameProblemLanguageResultExecution timeMemory
639367starchan걷기 (NOI12_walking)C++17
25 / 25
1 ms320 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define MX (int)3e5+5 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) signed main() { fast(); int l, n; cin >> l >> n; vector<in> tv(n+1); tv[0] = {-1,0}; vector<int> dp(n+1); for(int i = 1; i <= n; i++) cin >> tv[i].f >> tv[i].s; sort(tv.begin(), tv.end()); dp[1] = 1; int ans = 1; for(int i = 2; i <= n; i++) { dp[i] = 0; for(int j = 1; j < i; j++) { int prod = tv[i].s*tv[j].s; if((l*tv[j].s + tv[i].f*prod) < (l*tv[i].s + tv[j].f*prod)) dp[i] = max(dp[i], dp[j]); } dp[i]++; ans = max(ans, dp[i]); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...