Submission #499612

#TimeUsernameProblemLanguageResultExecution timeMemory
499612ac2huWalking (NOI12_walking)C++14
25 / 25
1 ms308 KiB
#include<bits/stdc++.h> using namespace std; signed main(){ iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int l,n;cin >> l >> n; vector<pair<int,int>> inp(n); for(int i = 0;i<n;i++){ cin >> inp[i].first >> inp[i].second; } sort(inp.begin(),inp.end()); vector<double> finish(n); for(int i = 0;i<n;i++){ finish[i] = (double)l/(double)inp[i].second + (double)inp[i].first; } vector<int> dp(n); for(int i = 0;i<n;i++){ dp[i] = 1; for(int j = i-1;j>=0;j--){ if(finish[j] > finish[i]) dp[i] = max(dp[j] + 1,dp[i]); } } cout << *max_element(dp.begin(),dp.end()) << "\n"; }
#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...