Submission #709460

# Submission time Handle Problem Language Result Execution time Memory
709460 2023-03-13T16:04:25 Z aedmhsn Walking (NOI12_walking) C++17
17 / 25
14 ms 22072 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=1e4+1e3+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);
}

// 3 1 2 1 1
# Verdict Execution time Memory Grader output
1 Correct 13 ms 21972 KB Output is correct
2 Correct 10 ms 22048 KB Output is correct
3 Correct 13 ms 21972 KB Output is correct
4 Incorrect 11 ms 21940 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 21972 KB Output is correct
2 Correct 12 ms 21972 KB Output is correct
3 Correct 11 ms 21972 KB Output is correct
4 Correct 12 ms 21972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 21956 KB Output is correct
2 Correct 12 ms 21948 KB Output is correct
3 Incorrect 12 ms 22024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 21972 KB Output is correct
2 Correct 13 ms 22072 KB Output is correct
3 Correct 13 ms 22024 KB Output is correct
4 Correct 14 ms 21988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 21972 KB Output is correct
2 Correct 11 ms 22052 KB Output is correct
3 Correct 11 ms 22052 KB Output is correct
4 Correct 12 ms 22016 KB Output is correct