Submission #548984

#TimeUsernameProblemLanguageResultExecution timeMemory
548984AbdelmagedNourWalking (NOI12_walking)C++17
25 / 25
1 ms328 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int l,n; cin>>l>>n; int dp[n]={1}; pair<int,int>a[n]; for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second; sort(a,a+n,greater<pair<int,int>>()); for(int i=1;i<n;i++){ dp[i]=1; for(int j=0;j<i;j++){ long long ti=a[i].first,vi=a[i].second; long long tj=a[j].first,vj=a[j].second; if(l*vj+ti*vi*vj>l*vi+tj*vi*vj)dp[i]=max(dp[i],1+dp[j]); } } cout<<*max_element(dp,dp+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...