Submission #388008

#TimeUsernameProblemLanguageResultExecution timeMemory
388008tushar_2658Walking (NOI12_walking)C++14
25 / 25
1 ms336 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 505; int l, n; struct DATA { int t, v; double x; }; DATA p[maxn]; int dp[maxn]; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(0); cin >> l >> n; for(int i = 1; i <= n; ++i){ cin >> p[i].t >> p[i].v; p[i].x = (double)(l / (double)p[i].v) + (double)p[i].t; } sort(p + 1, p + n + 1, [&](DATA x, DATA y){ if(x.t == y.t)return x.x > y.x; else return x.t < y.t; }); int ans = 0; for(int i = 1; i <= n; ++i){ dp[i] = 1; for(int j = 1; j < i; ++j){ if(p[j].x > p[i].x){ dp[i] = max(dp[i], dp[j] + 1); } } ans = max(ans, dp[i]); } cout << ans << '\n'; 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...