Submission #548984

# Submission time Handle Problem Language Result Execution time Memory
548984 2022-04-14T21:50:46 Z AbdelmagedNour Walking (NOI12_walking) C++17
25 / 25
1 ms 328 KB
#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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct