Submission #709459

# Submission time Handle Problem Language Result Execution time Memory
709459 2023-03-13T16:03:22 Z aedmhsn Walking (NOI12_walking) C++17
0 / 25
20 ms 39964 KB
#include <bits/stdc++.h>
using namespace std;
 
#define A first
#define B second
#define MP make_pair
#define ms(a, x) memset(a, x, sizeof(a)) 
 
 
#define boost() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pld;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);

const int mxN=2e4+5;

int dp[505][mxN], l, n;
vector <pii> v;

ll solve(int pos, int range){
    if(pos == n)
        return 0;
    if(dp[pos][range] != -1)
        return dp[pos][range];
    ll ret = solve(pos+1, range);
    if(v[pos].B < range)
        ret = max(ret, solve(pos+1, v[pos].B)+1);
    return dp[pos][range]=ret;
}

int main(){
    ms(dp, -1);
    cin >> l >> n;
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        v.push_back({x, l/y + x});
    } 
    sort(v.begin(), v.end());
    cout << solve(0, mxN-5);
}
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 39764 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 39836 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 39964 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 39808 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 39884 KB Memory limit exceeded
2 Halted 0 ms 0 KB -